@xdh211985【python】天气预报爬虫代码 中发帖

闲来无事,瞎鸡儿,趴一下天气预报。 
[image] 爬取当天的脚本代码如下:
import requests
from bs4 import BeautifulSoup
def get_weather():
url = "http://www.weather.com.cn/weather/101010200.shtml"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
}
try:
response = requests.get(url, headers=headers)
...