PUGE il y a 2 mois
Parent
commit
c0976f03e8
3 fichiers modifiés avec 18 ajouts et 15 suppressions
  1. 17 14
      app.py
  2. BIN
      buff_prices.db
  3. 1 1
      dmarket.py

+ 17 - 14
app.py

@@ -26,8 +26,11 @@ def get_buff_data(page_num):
         "Accept-Encoding": "gzip, deflate, br",
         "Connection": "keep-alive"
     }
-    
-    response = requests.get(url, headers=headers, params=querystring)
+    proxies={
+        "http": "http://USER660348-zone-custom-region-HK:e8b389:hk.rotgb.711proxy.com:10000",
+        "https": "http://USER660348-zone-custom-region-HK:e8b389:hk.rotgb.711proxy.com:10000",
+    }
+    response = requests.get(url, headers=headers, params=querystring, proxies = proxies)
     return response.json()
 
 def save_to_database(data):
@@ -122,19 +125,19 @@ def save_to_database(data):
 
 def main():
     ind = 0
-    while ind < 400:
-        ind = ind + 1
-        # 获取Buff数据
-        print("正在获取Buff数据,页码:" + str(ind))
-        response_data = get_buff_data(ind)
-            
-        if response_data.get('code') == 'OK':
-            # 保存到数据库
-            save_to_database(response_data)
-        else:
-            print(f"API返回错误: {response_data.get('msg')}")
+    # while ind < 400:
+    ind = ind + 1
+    # 获取Buff数据
+    print("正在获取Buff数据,页码:" + str(ind))
+    response_data = get_buff_data(ind)
+        
+    if response_data.get('code') == 'OK':
+        # 保存到数据库
+        save_to_database(response_data)
+    else:
+        print(f"API返回错误: {response_data.get('msg')}")
 
-        time.sleep(5)
+        # time.sleep(5)
         
 if __name__ == "__main__":
     main()

BIN
buff_prices.db


+ 1 - 1
dmarket.py

@@ -105,7 +105,7 @@ def main():
             save_to_database(response_data)
         else:
             print("API返回数据异常")
-        time.sleep(5)
+        time.sleep(60)
 
 if __name__ == "__main__":
     main()