|
@@ -0,0 +1,63 @@
|
|
|
+'''
|
|
|
+采购单位数据质量检查脚本
|
|
|
+编写人:刘苗苗
|
|
|
+'''
|
|
|
+import datetime
|
|
|
+import requests
|
|
|
+import pymysql
|
|
|
+#构造请求
|
|
|
+def buyer_portrait(name):
|
|
|
+ headers = {
|
|
|
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.67"
|
|
|
+ }
|
|
|
+ s = requests.Session()
|
|
|
+ response = s.post("https://www.jianyu360.cn/phone/login", headers=headers,data=
|
|
|
+ {
|
|
|
+ 'reqType': 'phoneLogin',
|
|
|
+ 'isAutoLogin': 'false',
|
|
|
+ 'phone': '19937989931',
|
|
|
+ 'password': '123456'
|
|
|
+ })
|
|
|
+ response1 = s.post("https://www.jianyu360.cn/bigmember/subVipPortrait/buyer/getData", headers=headers,params=
|
|
|
+ {"buyer":name,"match":"","exactMatch":"0","matchRange":"","scopeClass":"","timeRange":""}
|
|
|
+ )
|
|
|
+ response2 = s.post("https://www.jianyu360.cn/bigmember/portrait/contacts", headers=headers, params=
|
|
|
+ {"entName":name,"entType":"0"}
|
|
|
+ )
|
|
|
+ r1=response1.json()
|
|
|
+ r2=response2.json()
|
|
|
+ result=r1['data']['bidamount_count']
|
|
|
+ result_list=r2['data']['list']
|
|
|
+ result1=len(result_list)
|
|
|
+ return result,result1
|
|
|
+#测试库数据源链接
|
|
|
+mysqlconn = pymysql.connect(
|
|
|
+ host='192.168.3.217',
|
|
|
+ port=4000,
|
|
|
+ db='data_quality',
|
|
|
+ user='root',
|
|
|
+ password='=PDT49#80Z!RVv52_z',
|
|
|
+ charset='utf8')
|
|
|
+cursor = mysqlconn.cursor()
|
|
|
+#需要导出的数据,sql语句
|
|
|
+sql = """SELECT * FROM buyer0801 where id < 500000 """
|
|
|
+#执行单条sql语句
|
|
|
+cursor.execute(sql)
|
|
|
+#执行多条
|
|
|
+tj_result = cursor.fetchall()
|
|
|
+#一起提交
|
|
|
+mysqlconn.commit()
|
|
|
+#status=2 80%正确,portrait_empty_flag=0地区,画像内容都是空,
|
|
|
+
|
|
|
+for info in tj_result:
|
|
|
+ name=info[2]
|
|
|
+ result,result1=buyer_portrait(name)
|
|
|
+ if result == 0 and result1 == 0:
|
|
|
+ print(info,result,result1)
|
|
|
+ update_sql = "UPDATE buyer0801 SET portrait_empty_flag=0 WHERE name_id='{}'".format(info[1])
|
|
|
+ cursor.execute(update_sql)
|
|
|
+ mysqlconn.commit()
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|