|
|
@@ -137,16 +137,14 @@ def main():
|
|
|
city = temp
|
|
|
district = ""
|
|
|
else:
|
|
|
- print(pid)
|
|
|
cursor1.execute('select city from district where id = ?', (pid,))
|
|
|
te = cursor1.fetchone()
|
|
|
city = te[0]
|
|
|
district = temp
|
|
|
- print(district, city, "--------------")
|
|
|
province_id = (str(row[0]))[:2]
|
|
|
province = province_dict.get(province_id)
|
|
|
+ print(city, district, province, "+++++++++++++++++++++")
|
|
|
try:
|
|
|
- # if district == '唐河县' or city == "郑州市" or city == "市辖区":
|
|
|
today_url = f"https://v0.yiketianqi.com/api?unescape=1&version=v62&appid={app_id}&appsecret={app_secret}&adcode={id}"
|
|
|
today_response = requests.get(today_url)
|
|
|
today_data = json.loads(today_response.text)
|
|
|
@@ -155,17 +153,14 @@ def main():
|
|
|
INSERT OR REPLACE INTO `day_data` (`id`,`province`, `city`, `district`, content) VALUES (?, ?, ?, ?, ?)
|
|
|
"""
|
|
|
cursor1.execute(today_sql, (i, province, city, district,str(today_data)))
|
|
|
- print(city, district, province, "---------------------")
|
|
|
server_day_url = f"https://v0.yiketianqi.com/api?unescape=1&version=v91&appid={app_id}&appsecret={app_secret}&adcode={id}"
|
|
|
server_day_response = requests.get(server_day_url)
|
|
|
server_day_data = json.loads(server_day_response.text)
|
|
|
if "errcode" not in server_day_data.keys():
|
|
|
- logging.warning(f"{province, city, district} server day weather success")
|
|
|
server_sql = f"""
|
|
|
INSERT OR REPLACE INTO `server_day_data` (`id`,`province`, `city`, `district`, `content`) VALUES (?, ?, ?, ?, ?)
|
|
|
"""
|
|
|
cursor1.execute(server_sql, (i, province, city, district,str(server_day_data),))
|
|
|
- print(city, district, province, "+++++++++++++++++++++")
|
|
|
conn1.commit()
|
|
|
except Exception as e:
|
|
|
print(e)
|