这是我使用遍历所有元素的代码:美丽的汤未选择任何元件
soup_top = bs4.BeautifulSoup(r_top.text, 'html.parser')
selector = '#ContentPlaceHolder1_gvDisplay table tr td:nth-of-type(3) a'
for link in soup_top.select(selector):
print(link)
在JavaScript中使用时,相同的选择给出的57的长度:
document.querySelectorAll("#ContentPlaceHolder1_gvDisplay table tr td:nth-of-type(3) a").length;
我认为,也许我没有正确地获取网页的内容。然后我保存了网页的本地副本,但Beautiful Soup中的选择器仍然没有选择任何内容。这里发生了什么?
这是website我使用的是代码。
你能分享HTML吗?没有它,这将是很难看到发生了什么事情。 –
正如已经提到的,我们不知道没有看到html –
@Kristof我已经添加了一个链接到网站,我试图刮。 –