|
|
@@ -122,48 +122,36 @@ def main():
|
|
|
city = temp
|
|
|
district = ""
|
|
|
else:
|
|
|
- if pid == 620500000000:
|
|
|
- print(pid, '=================================')
|
|
|
- cursor1.execute('select city from district where id = ?', (pid,))
|
|
|
- te = cursor1.fetchone()
|
|
|
- city = te[0]
|
|
|
- district = temp
|
|
|
- print(district, city, "-------%%%%%%%%%%%-------")
|
|
|
- else:
|
|
|
- print(pid)
|
|
|
- cursor1.execute('select city from district where id = ?', (pid,))
|
|
|
- te = cursor1.fetchone()
|
|
|
- city = te[0]
|
|
|
- district = temp
|
|
|
- print(district, city, "--------------")
|
|
|
+ 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)
|
|
|
|
|
|
- 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)
|
|
|
- if "errcode" not in today_data.keys():
|
|
|
- today_sql = """
|
|
|
- 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, "---------------------")
|
|
|
- if hour in special_time:
|
|
|
- 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():
|
|
|
- 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()
|
|
|
+ # 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)
|
|
|
+ if "errcode" not in today_data.keys():
|
|
|
+ today_sql = """
|
|
|
+ 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():
|
|
|
+ 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()
|
|
|
conn1.close()
|
|
|
- print("start sleep...")
|
|
|
- time.sleep(3600)
|
|
|
-
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|