从天气网分析,可以查询每个月的天气情况,这里按照url规则,传入年月,获取数据,最后进行可视化展示,最终效果:
下面是获取过程:
第一步:
import requests
def get_weather(month):
url = f"https://lishi.tianqi.com/nanning/{month}.html"
response = requests.get(url)
data = response.text
print(data)
return data
get_weather("202307")
提示如下:
PS D:\soft\src\python-src\python05-icecream> & D:/soft/python/Python38/python.exe d:/soft/src/python-src/python05-icecream/weather.py
🍦 data: ('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>403 '
"Forbidden</title></head><body><h1>403 Forbidden&l