|
|
@@ -76,9 +76,9 @@ def init_data():
|
|
|
|
|
|
def main():
|
|
|
district = District.objects.all()
|
|
|
- init_data()
|
|
|
+ # init_data()
|
|
|
logging.warning("up...")
|
|
|
- results = District.objects.filter(id__gt = 65).filter(id__lt = 80)
|
|
|
+ results = District.objects.filter(id__gt = 32).filter(id__lt = 80)
|
|
|
# 更新数据
|
|
|
for row in results:
|
|
|
temp = row.city # 东城区
|
|
|
@@ -103,7 +103,6 @@ def main():
|
|
|
today_url = f"https://v0.yiketianqi.com/api?unescape=1&version=v62&appid={app_id}&appsecret={app_secret}&adcode={city_id}"
|
|
|
today_response = requests.get(today_url, timeout=5)
|
|
|
today_data = json.loads(today_response.text)
|
|
|
- print("today_data")
|
|
|
if "errcode" not in today_data.keys():
|
|
|
cityid = today_data.get("cityid", "")
|
|
|
DayData.objects.update_or_create(
|
|
|
@@ -119,7 +118,6 @@ def main():
|
|
|
server_day_url = f"https://v0.yiketianqi.com/api?unescape=1&version=v91&appid={app_id}&appsecret={app_secret}&adcode={city_id}&ext=hours,aqi,life"
|
|
|
server_day_response = requests.get(server_day_url, timeout=5)
|
|
|
server_day_data = json.loads(server_day_response.text)
|
|
|
- print("server today_data")
|
|
|
if "errcode" not in server_day_data.keys():
|
|
|
cityid = today_data.get("cityid", "")
|
|
|
ServerDayData.objects.update_or_create(
|