Bladeren bron

update yueka spider 3.5.4

charley 2 weken geleden
bovenliggende
commit
6ec9bee060
3 gewijzigde bestanden met toevoegingen van 37 en 10 verwijderingen
  1. 27 5
      yueka_spider/settings.py
  2. 1 1
      yueka_spider/start_yueka_spider.py
  3. 9 4
      yueka_spider/yk_new_daily_spider.py

+ 27 - 5
yueka_spider/settings.py

@@ -19,20 +19,42 @@ HEADERS = {
     "Content-Type": "application/json",
     "deviceid": "110bec91-951f-4346-8195-95700fdb8c1d",
     "brand": "google",
+    "channel": "JC",
     "os": "android",
     "content-type": "application/json; charset=utf-8",
     # "authori-zation": "a-209a2707889f473688a742c4bac06eed",
     "systemversion": "30",
     "theme": "light",
     "lang": "zh",
-    "verse-ua": "5282360bfafdd013cec4258b31c53f13",
-    "version": "1.0.7",
+    "verse-ua": "ed5866264fee2419a78abd8f0feabd6f",
+    "version": "1.1.1",
     "isphysicaldevice": "true",
-    "sktime": "1766401868617",
-    "cid": "42661545",
-    "sk": "f0635a5c5fee2a9d137358264721e7ff" # 每次版本变化 也需要修改
+    "sktime": "1770608542291",
+    "cid": "08295441",
+    "sk": "0ac56318c28de85c57fe74995ed6678d" # 每次版本变化 也需要修改
 }
 
+# headers = {
+#     "User-Agent": "Dart/3.5 (dart:io)",
+#     "Accept-Encoding": "gzip",
+#     "deviceid": "110bec91-951f-4346-8195-95700fdb8c1d",
+#     "brand": "google",
+#     "channel": "JC",
+#     "os": "android",
+#     "content-type": "application/json; charset=utf-8",
+#     "authori-zation": "a-e22bdf9887a846e0ab04fa45fad22396",
+#     "systemversion": "30",
+#     "theme": "light",
+#     "lang": "zh",
+#     "verse-ua": "ed5866264fee2419a78abd8f0feabd6f",
+#     "version": "1.1.1",
+#     "isphysicaldevice": "true",
+#     "sktime": "1770608542291",
+#     "cid": "08295441",
+#     "sk": "0ac56318c28de85c57fe74995ed6678d"
+# }
+
+
 
 
 def after_log(retry_state):

+ 1 - 1
yueka_spider/start_yueka_spider.py

@@ -30,7 +30,7 @@ def schedule_task():
     # login_main()
     # time.sleep(5)
     
-    run_threaded(yueka_main, log=logger)
+    # run_threaded(yueka_main, log=logger)
     
     # 每天  定时更新token
     schedule.every().day.at("00:01").do(run_threaded, login_main)

+ 9 - 4
yueka_spider/yk_new_daily_spider.py

@@ -118,7 +118,7 @@ def get_product(log, items, sql_pool, last_product_id):
     should_stop = False
     info_list = []
     for item in items:
-        product_id = item.get("code")
+        product_id = item.get("code",'')
         if not product_id:
             log.warning(f"Warning {inspect.currentframe().f_code.co_name}: No product_id found")
             continue
@@ -166,8 +166,13 @@ def get_all_sold_data(log, sql_pool, last_product_id):
         
         # 处理 items 数据
         parse_shop_items(log, items, sql_pool)
-        
-        stop_page = get_product(log, items, sql_pool, last_product_id)
+
+        try:
+            stop_page = get_product(log, items, sql_pool, last_product_id)
+        except Exception as e:
+            log.error(f"Error fetching product: {e}")
+            stop_page = True
+
         if stop_page:
             log.info(
                 f"----------------- The product_id {last_product_id} is the last product_id, stop fetching -----------------")
@@ -212,7 +217,7 @@ def yueka_main(log):
                 "SELECT product_id FROM yueka_product_record ORDER BY finish_time DESC LIMIT 1")
             # 如果表中没有数据,last_product_id_result 为 None
             last_product_id = last_product_id_result[0] if last_product_id_result else None
-            
+
             get_all_sold_data(log, sql_pool, last_product_id)
         except Exception as e:
             log.error(f"Error fetching last_product_id: {e}")