在使用.find方法时,BeautifulSoup没有找到所有标签?

我正在尝试使用Python中的BeautifulSoup从https://github.com/trending抓取趋势存储库的数量。该代码应该找到所有带有class_ =“ Box-row”的标签,然后打印找到的数字。在该站点上,趋势存储库的实际数量为25,但是代码仅返回9。

我尝试将解析器从“ html.parser”更改为“ lxml”,但都返回了相同的结果。

page = requests.get('https://github.com/trending')
soup = BeautifulSoup(page.text,'html.parser')

soup = BeautifulSoup(page.text)
repo = soup.find(class_ = "Box-row")
print(len(repo))

在html中,有25个带有“ Box-row”类属性的标签,因此我希望看到print(len(repo))= 25,但它是9。

shaliang8 回答:在使用.find方法时,BeautifulSoup没有找到所有标签?

尝试一下:

repo = soup.find_all("article",{"class":"Box-row"})
本文链接:https://www.f2er.com/3126687.html

大家都在问