(求解答)初学者做了一个关于微博热搜的爬虫代码但是运行以后不显示任何结果如图:
代码没有问题(因为开始可以运行有结果现在可以运行但是没有结果),从网上找的别的代码也是一样的,不报错,也没有运行结果。
附上代码: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; Win64; x64) AppleWebKit/537.36 (KHTML, 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.HTML(resp1)
title = resp2.xpath('//*[@id="pl_top_realtimehot"]/table/tbody/tr/td/a/text()')
print (time.strftime("%F,%R")+'微博热搜\n')
for i in range(11):
print (' '.join([title[i]]),'\n')
time.sleep(1)
求解答,很心急。
有显示运行结束吗?我用你的代码能跑出结果
没有开始运行以后就没有任何反应的呆着不动了,但是不报错不结束