import requests
from bs4 import BeautifulSoup
url = 'https://s.weibo.com/top/summary?cate=realtimehot'
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_encoding
text = urls.text
soup = BeautifulSoup(text, 'lxml')
a = soup.find_all(class_="td-02")
b = [i.get_text() for i in a]
print('热搜榜')
print('{:25}'.format('标题(搜索数)'))
for i,y in zip(b,a):
print('{:10}\t{}\n'.format(i,y))