Ver Fonte

所以查询页面api全部抓取完毕

sptkw há 1 ano atrás
pai
commit
fd5fc2d0a3
1 ficheiros alterados com 0 adições e 72 exclusões
  1. 0 72
      amac/member_api.py

+ 0 - 72
amac/member_api.py

@@ -1,72 +0,0 @@
-import http.client
-import json
-import random
-
-from Config import mysql_pool
-
-conn = http.client.HTTPSConnection("gs.amac.org.cn")
-
-payload = "{}"
-
-headers = {
-    'Accept': "*/*",
-    'Accept-Encoding': "gzip, deflate, br",
-    'User-Agent': "PostmanRuntime-ApipostRuntime/1.1.0",
-    'Connection': "keep-alive",
-    'Content-Type': "application/json"
-}
-
-http_url = "/amac-infodisc/api/pof/pofMember"
-page = 0
-size = 20
-conn.request("POST", http_url + "?rand=0.680639590677673&page=0&size=20", payload, headers)
-
-res = conn.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")
-    print("\n开始插入数据==>\n")
-    mysql_pool.insert('amac_member', data_to_insert)
-
-    # # 更新数据示例
-    # update_data = {'column1': 'new_value'}
-    # update_condition = {'id': 1}
-    # mysql_pool.update('your_table', update_data, update_condition)
-
-    # 开始循环
-
-    if (json_obj.get("totalPages") > 1):
-        for i in range(1, json_obj.get("totalPages")):
-            # 生成一个0到1之间的随机浮点数,并格式化为指定的小数位数
-            random_float = round(random.random(), 14)  # 保留14位小数
-            page = i
-            size = 20
-            conn.request("POST",
-                         http_url + "?rand=(" + str(random_float) + ")&page=" + str(page) + "&size=" + str(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("\n开始插入数据==>" + str(i) + "*20\n")
-                mysql_pool.insert('amac_member', 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}")