![](/img/trans.png)
[英]Using find_all to find a certain class in BS4 with BeautifulSoup
[英]BeautifulSoup (bs4) does not find all tags
我正在使用Python 3.5和bs4
以下代碼不會從指定的網站檢索所有表。 該頁面有14個表,但是代碼的返回值為2。我不知道發生了什么。 我手動檢查了HTML,但找不到為什么它不起作用的原因。 每個表似乎沒有什么特別的。
import bs4
import requests
link = "http://www.pro-football-reference.com/players/B/BradTo00.htm"
htmlPage = requests.get(link)
soup = bs4.BeautifulSoup(htmlPage.content, 'html.parser')
all_tables = soup.findAll('table')
print(len(all_tables))
這是怎么回事?
編輯:我應該澄清。 如果我檢查湯變量,它包含了我希望看到的所有表。 如何使用findAll方法從湯中提取那些表?
此頁面由javascript呈現,如果您在瀏覽器中禁用javascrip,您會注意到此頁面只有兩個表。 我建議在這種情況下使用硒。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.