import requestsfrom bs4 import BeautifulSoupurl = 'http://top.baidu.com/buzz?b=341&c=513&fr=topbuzz_b1'headers = {'User-Agent':'Mozilla/5.0 (Windows NT 6.3; Win64; x64)' 'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'}urls = requests.get(url, headers=headers)urls.encoding = urls.apparent_encodingtext = urls.textsoup = BeautifulSoup(text, 'lxml')c = soup.find_all(class_="list-title")he = [i.get_text() for i in c]q = soup.find_all('td', class_="last")qq = [i.get_text().strip() for i in q]print('{:25} {}'.format('标题', '搜索指数'))