|
|
@@ -76,6 +76,28 @@ def init_data():
|
|
|
|
|
|
|
|
|
def main():
|
|
|
+ logging.warning("up today ...")
|
|
|
+ day_data = DayData.objects.all()
|
|
|
+ for day_obj in day_data:
|
|
|
+ today_url = f"http://v0.yiketianqi.com/api?unescape=1&version=v62&appid=69334222&appsecret=2u4bHXHD&cityid={day_obj.cityid}"
|
|
|
+ today_response = requests.get(today_url, timeout=5)
|
|
|
+ today_data = json.loads(today_response.text)
|
|
|
+ if "errcode" not in today_data.keys():
|
|
|
+ day_obj.content = str(today_data)
|
|
|
+ day_obj.save()
|
|
|
+ logging.warning("over today ...")
|
|
|
+ logging.warning("up server day ...")
|
|
|
+ server_days = ServerDayData.objects.all()
|
|
|
+ for server_day_obj in server_days:
|
|
|
+ server_day_url = f"http://v0.yiketianqi.com/api?unescape=1&version=v91&appid=69334222&appsecret=2u4bHXHD&cityid={server_day_obj.cityid}&ext=hours,aqi,life"
|
|
|
+ server_day_response = requests.get(server_day_url, timeout=5)
|
|
|
+ server_day_data = json.loads(server_day_response.text)
|
|
|
+ if "errcode" not in server_day_data.keys():
|
|
|
+ server_day_obj.content = str(server_day_data)
|
|
|
+ server_day_obj.save()
|
|
|
+ logging.warning("over server day ...")
|
|
|
+
|
|
|
+ """
|
|
|
district = District.objects.all()
|
|
|
# init_data()
|
|
|
logging.warning("up...")
|
|
|
@@ -134,7 +156,7 @@ def main():
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
logging.warning("over...")
|
|
|
-
|
|
|
+ """
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
main()
|