yf_yzl 2 лет назад
Родитель
Сommit
966e23812c
1 измененных файлов с 5 добавлено и 7 удалено
  1. 5 7
      crond_script/crond_weather.py

+ 5 - 7
crond_script/crond_weather.py

@@ -83,7 +83,7 @@ def main():
         'Accept-Encoding': 'gzip, deflate, br',
         'Connection': 'keep-alive',
     }
-    day_data = DayData.objects.filter(id__gte=904)
+    day_data = DayData.objects.filter(id__gte=967)
     for day_obj in day_data:
         logging.warning(day_obj.cityid)
         today_url = f"http://v0.yiketianqi.com/api?unescape=1&version=v62&appid=69334222&appsecret=2ME6U58N&cityid={day_obj.cityid}"
@@ -103,8 +103,9 @@ def main():
                     if "errcode" not in today_data.keys():
                         day_obj.content = str(today_data)
                         day_obj.save()
+                        logging.warning(f"request again success: {day_obj.cityid}")
         except Exception as e:
-            logging.warning(f"request fail again : {day_obj.cityid}")
+            logging.warning(f"request fail again : {day_obj.cityid} {e.args}")
         time.sleep(random.randint(1, 5))
 
     logging.warning("up server day ...")
@@ -128,15 +129,12 @@ def main():
                     if "errcode" not in server_day_data.keys():
                         server_day_obj.content = str(server_day_data)
                         server_day_obj.save()
+                        logging.warning(f"request again success: {server_day_obj.cityid}")
         except Exception as e:
-            logging.warning(f"cityid {server_day_obj.cityid}  error {e} {server_day_response.text}")
+            logging.warning(f"request fail again : {server_day_obj.cityid} {e.args}")
         time.sleep(random.randint(1, 5))
     logging.warning("over server day ...")
 
-
-
-
-
     """
     district = District.objects.all() 
     # init_data()