1、代码
import requests
from bs4 import BeautifulSoup
url = 'http://www.weather.com.cn/weather/101200101.shtml'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
temperature = soup.find(class_='tem').text.strip()
weather = soup.find(class_='wea').text.strip()
print(f'武汉当前天气:{
weather},温度:{
temperature}')
2、效果
3、改进
后续做成可视化。