|
@@ -5,7 +5,8 @@ import time
|
|
|
import Utils
|
|
import Utils
|
|
|
from Config import mysql_pool, conn, headers, page, size
|
|
from Config import mysql_pool, conn, headers, page, size
|
|
|
|
|
|
|
|
-print("开始时间(精确到毫秒):", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), time.time() * 1000)
|
|
|
|
|
|
|
+start_time = Utils.data_time()
|
|
|
|
|
+print("开始时间(精确到毫秒)[终止机构]:", start_time)
|
|
|
|
|
|
|
|
|
|
|
|
|
# 因为这里数据一条人员信息amac_member_user中包含了对应的多个证书,所以需要先循环把证书拿出来
|
|
# 因为这里数据一条人员信息amac_member_user中包含了对应的多个证书,所以需要先循环把证书拿出来
|
|
@@ -83,51 +84,7 @@ for amac_org_type_item in amac_org_type:
|
|
|
{"userName": "", "certCode": "", "certName": "", "userId": str(user_id), "page": "1"})
|
|
{"userName": "", "certCode": "", "certName": "", "userId": str(user_id), "page": "1"})
|
|
|
|
|
|
|
|
http_url = "/amac-infodisc/api/pof/person"
|
|
http_url = "/amac-infodisc/api/pof/person"
|
|
|
- random_float = round(random.random(), 14)
|
|
|
|
|
- print(f"请求url={http_url}?rand={random_float}&page={this_page}&size={this_size}")
|
|
|
|
|
|
|
|
|
|
- conn.request("POST",
|
|
|
|
|
- f"{http_url}?rand={random_float}&page={this_page}&size={this_size}",
|
|
|
|
|
- payload, headers)
|
|
|
|
|
|
|
+ Utils.get_page_result(http_url, this_page, this_size, payload, headers, conn, savetodb, __file__)
|
|
|
|
|
|
|
|
- res = Utils.get_conn_result(conn, __file__).getresponse()
|
|
|
|
|
- data = res.read()
|
|
|
|
|
- json_str = data.decode("utf-8")
|
|
|
|
|
- # print("JSON String", json_str)
|
|
|
|
|
-
|
|
|
|
|
- try:
|
|
|
|
|
- json_obj = json.loads(json_str)
|
|
|
|
|
- print("获取到总条数为:", json_obj.get("totalPages"))
|
|
|
|
|
-
|
|
|
|
|
- data_to_insert = json_obj.get("content")
|
|
|
|
|
-
|
|
|
|
|
- if data_to_insert is not None:
|
|
|
|
|
- # 先睡一秒,确保峰值不会太高
|
|
|
|
|
- time.sleep(1)
|
|
|
|
|
-
|
|
|
|
|
- print(f"\n开始插入数据==>{this_page}*{this_size}\n")
|
|
|
|
|
- savetodb(data_to_insert)
|
|
|
|
|
-
|
|
|
|
|
- if json_obj.get("totalPages") > 1:
|
|
|
|
|
- for i in range(1, json_obj.get("totalPages")):
|
|
|
|
|
- this_page = i
|
|
|
|
|
- print(f"请求url={http_url}?rand={random_float}&page={this_page}&size={this_size}")
|
|
|
|
|
- conn.request("POST",
|
|
|
|
|
- f"{http_url}?rand={random_float}&page={this_page}&size={this_size}",
|
|
|
|
|
- payload, headers)
|
|
|
|
|
- res = conn.getresponse()
|
|
|
|
|
- data = res.read()
|
|
|
|
|
- json_str = data.decode("utf-8")
|
|
|
|
|
- print("JSON String", json_str)
|
|
|
|
|
- try:
|
|
|
|
|
- json_obj_arr = json.loads(json_str)
|
|
|
|
|
- print("获取到总条数为:", json_obj_arr.get("totalPages"))
|
|
|
|
|
- data_to_insert = json_obj_arr.get("content")
|
|
|
|
|
- print(f"\n开始插入数据==>{i}*{this_size}\n")
|
|
|
|
|
- savetodb(data_to_insert)
|
|
|
|
|
- except json.JSONDecodeError as e:
|
|
|
|
|
- print(f"循环 Error decoding JSON: {e}")
|
|
|
|
|
- except json.JSONDecodeError as e:
|
|
|
|
|
- print(f"请求 Error decoding JSON: {e}")
|
|
|
|
|
-
|
|
|
|
|
- print("结束时间(精确到毫秒):", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), time.time() * 1000)
|
|
|
|
|
|
|
+ print(f"[终止机构]结束时间(精确到毫秒): {Utils.data_time()} - {start_time}")
|