爬取网址:微博热搜榜:https://s.weibo.com/top/summary?Refer=top_hot&topnav=1&wvr=6
1.request请求
response = requests.get('https://s.weibo.com/top/summary?Refer=top_hot&topnav=1&wvr=6')
2.返回数据转bs对象
soup = BeautifulSoup(response.content, "html5lib")
3.分析返回html
view-source:https://s.weibo.com/top/summary?Refer=top_hot&topnav=1&wvr=6
4.取出标题
for sou in soup.find_all("div",class_='data'):
#正则取出名字
so = str(sou)
#关键字
rekeyword = r'target="_blank">(.*?)</a>'