import requests
import re
headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36'}
data = {'cate':'realtimehot'}
try:
r = requests.get('http://s.weibo.com/top/summary?',params=data,headers=headers)
print(r.url)
if r.status_code == 200:
html = r.text
except:
html = ""
pattern=re.compile('
(.*?)
',re.S)
result=re.findall(pattern,html)
for i in range(1,11): #找出热度前10名的关键字,排在第一个的不是热榜内容,所以i从1开始。
print(result[i])