def gx_qyid(z, eid): print('开始更新企业id') qyurl = f'http://jzsc.mohurd.gov.cn/api/webApi/dataservice/query/comp/list?complexname={z}&pg=0&pgsz=15&total=0' resp1 = requests.get(url=qyurl, headers=headers) asddd2 = jd_nx(data=f'{resp1.text}') if len(asddd2['data']['list']) == 0: print('没有这个公司异常') Mysql.gxqy_fupa(cx_state='3', eid=eid) else: qyid = asddd2['data']['list'][0]['QY_ID'] Mysql.update_qyid(qyurl=qyid, eid=eid) # 更新企业id return qyid
def gx_qyid(self): try: print('开始更新企业id') qyurl = f'http://jzsc.mohurd.gov.cn/api/webApi/dataservice/query/comp/list?complexname={self.z}&pg=0&pgsz=15&total=0' resp1 = requests.get(url=qyurl, headers=self.headers, proxies=self.ipz(), timeout=10) ew = resp1.text if str(ew).find('服务器繁忙,请稍后重试') != -1: print('服务器繁忙,请稍后重试') else: asddd2 = self.jd_nx(data=f'{resp1.text}') if len(asddd2['data']['list']) == 0: print('没有这个公司异常') Mysql.gxqy_fupa(cx_state='3', eid=self.qyid) else: qyid = asddd2['data']['list'][0]['QY_ID'] Mysql.update_qyid(qyurl=qyid, eid=self.qyid) #更新企业id print('企业更新完毕') return qyid except Exception as e: qq = str(e) if qq.find("HTTPConnectionPool") != -1: print('ip失效') Mysql.dele_token(token=self.jichu) print('token删除成功') Mysql.token(token=self.jichu) self.jichu = self.jichutoken()[0] self.ip = { "http": "http://" + self.jichutoken()[1], "https": "https://" + self.jichutoken()[1] } else: print('不存在') print(e, '基础信息错误')