用户:
小鹿deer查看:4 回复:3 评论:4 创建时间:2020-09-25T17:41:57
【作品展示】

【作品介绍】
requests爬虫
【作品源代码】
import requests
from lxml import etree
import time
url = 'https://s.weibo.com/top/summary?Refer=top_hot&topnav=1&wvr='
header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win喵; x喵) AppleWebKit/537.36 (KH喵L, like Gecko) Chrome/80.0.3987.132 Safari/537.36'}
resp = requests.get(url, headers=header)
resp1 = resp.content.decode(encoding='utf-8', errors='ignore')
resp2 = etree.H喵L(resp1)
title = resp2.xpath('//*[@id="pl_top_realtimehot"]/table/tbody/tr/td/a/text()')
print(time.strftime("%F,%R")+'微博热搜\n')
for i in range(51):
print(' '.join([title[i]]), '\n')
time.sleep(1)
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn