|
@@ -83,7 +83,8 @@ def main():
|
|
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
'Accept-Encoding': 'gzip, deflate, br',
|
|
|
'Connection': 'keep-alive',
|
|
'Connection': 'keep-alive',
|
|
|
}
|
|
}
|
|
|
- day_data = DayData.objects.filter(id__gte=967)
|
|
|
|
|
|
|
+ day_data = DayData.objects.filter(id__gte=1062)
|
|
|
|
|
+ today_error = 0
|
|
|
for day_obj in day_data:
|
|
for day_obj in day_data:
|
|
|
logging.warning(day_obj.cityid)
|
|
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}"
|
|
today_url = f"http://v0.yiketianqi.com/api?unescape=1&version=v62&appid=69334222&appsecret=2ME6U58N&cityid={day_obj.cityid}"
|
|
@@ -104,10 +105,15 @@ def main():
|
|
|
day_obj.content = str(today_data)
|
|
day_obj.content = str(today_data)
|
|
|
day_obj.save()
|
|
day_obj.save()
|
|
|
logging.warning(f"request again success: {day_obj.cityid}")
|
|
logging.warning(f"request again success: {day_obj.cityid}")
|
|
|
|
|
+ else:
|
|
|
|
|
+ logging.warning(f"cityid {day_obj.cityid} error_code {today_response.status_code} again request fail")
|
|
|
|
|
+ logging.error(f"error {today_error}")
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
logging.warning(f"request fail again : {day_obj.cityid} {e.args}")
|
|
logging.warning(f"request fail again : {day_obj.cityid} {e.args}")
|
|
|
- time.sleep(random.randint(1, 5))
|
|
|
|
|
|
|
+ time.sleep(2)
|
|
|
|
|
+ today_error += 1
|
|
|
|
|
|
|
|
|
|
+ server_error = 0
|
|
|
logging.warning("up server day ...")
|
|
logging.warning("up server day ...")
|
|
|
server_days = ServerDayData.objects.all()
|
|
server_days = ServerDayData.objects.all()
|
|
|
for server_day_obj in server_days:
|
|
for server_day_obj in server_days:
|
|
@@ -130,10 +136,14 @@ def main():
|
|
|
server_day_obj.content = str(server_day_data)
|
|
server_day_obj.content = str(server_day_data)
|
|
|
server_day_obj.save()
|
|
server_day_obj.save()
|
|
|
logging.warning(f"request again success: {server_day_obj.cityid}")
|
|
logging.warning(f"request again success: {server_day_obj.cityid}")
|
|
|
|
|
+ else:
|
|
|
|
|
+ logging.warning(f"cityid {day_obj.cityid} error_code {server_day_response.status_code} again request afil")
|
|
|
|
|
+ logging.error(f"error {server_error}")
|
|
|
except Exception as e:
|
|
except Exception as e:
|
|
|
logging.warning(f"request fail again : {server_day_obj.cityid} {e.args}")
|
|
logging.warning(f"request fail again : {server_day_obj.cityid} {e.args}")
|
|
|
- time.sleep(random.randint(1, 5))
|
|
|
|
|
- logging.warning("over server day ...")
|
|
|
|
|
|
|
+ time.sleep(2)
|
|
|
|
|
+ server_error += 1
|
|
|
|
|
+
|
|
|
|
|
|
|
|
"""
|
|
"""
|
|
|
district = District.objects.all()
|
|
district = District.objects.all()
|