BeautifulSoup没有找到带有风格的tr标签

时间:2018-03-11 17:49:49

标签: python python-3.x beautifulsoup python-3.6

我正在尝试完成以下操作: 打开一个网页,获取带粗体字的tr标签,然后过滤链接

这很有效:

response = urllib2.urlopen("https://wiki.guildwars.com/wiki/Weekly_activities")
data = response.read()
soup = BeautifulSoup(data, 'html.parser')
weekliesunsorted = soup.findAll('tr', style="font-weight: bold;")
pvebonus = weekliesunsorted[0].findAll('a')[0]
#and so on...

但不幸的是,这段代码没有,fluxunsorted变量为空,但tr行确实存在

response = urllib2.urlopen("https://wiki.guildwars.com/wiki/Flux")
data = response.read()
soup = BeautifulSoup(data, 'html.parser')
fluxunsorted = soup.findAll('tr', style="font-weight:bold;") #empty?
flux = fluxunsorted[0].findAll('a')[0]

这就是为什么我让索引超出范围错误。

为什么列表为空?

0 个答案:

没有答案
相关问题