from bs4 import BeautifulSoup
from pyecharts.charts import Bar
from pyecharts import options as opts
import requests
ALL_DATA = []
def parse_page(url):
headers ={
‘User-Agent’:‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36’
}
response = requests.get(url,headers=headers)
text=response.content.decode(‘utf-8’)
soup = BeautifulSoup(text,‘html5lib’)
conMidtab = soup.find(‘div’,class_=‘conMidtab’)
tables = conMidtab.find_all(‘table’)
for table in tables:
trs = table.find_all(‘tr’)[2:]
for index,tr in enumerate(trs):
tds = tr.find_all(‘td’)
city_td = tds[0]
if index ==0:
city_td = tds[1]
city = list(city_td.stripped_strings)[0]
temp_td =tds[-2]
min_temp = list(temp_td.stripped_stri