📌 📄 内容摘要:
@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)
...
────────── 链接信息 ────────── 🔗 论坛链接: linux.do 📎 访问地址: https://linux.do/t/topic/305147/1 ─────────────────────────────
📢 来源:LINUX DO