Beautiful Soup findAll()找到其中一半

问题描述 投票:0回答:1

我正在尝试删除有关法国办事处价格的信息,并且我成功开发了代码以删除我需要的所有信息。

尽管,我很快注意到输出数量出了点问题,更确切地说,我的算法只返回了网站每一页上出现的事件的一半。

这是基本代码的样子:

from urllib.request import Request, urlopen
from bs4 import BeautifulSoup

page = "https://www.bureauxlocaux.com/recherche/?transaction_type=sale&realty_type=office&page=1"
req = Request(page, headers={'User-Agent': 'Mozilla/5.0'})
web_byte = urlopen(req).read()
webpage = web_byte.decode('utf-8')
bs = BeautifulSoup(webpage, 'html.parser')
announces = bs.findAll('li',{'class':'item-card'})

[就像这里建议的Beautiful Soup findAll doesn't find them all,我已经在使用html.parser了,我已经与其他人尝试过,但是徒劳。

我仍然不明白为什么它只选择页面的前半部分,而html代码显然包含了所有这些。

python beautifulsoup findall
1个回答
0
投票

您在页面上看到的数据将存储为Json。您可以使用json模块将其提取。

© www.soinside.com 2019 - 2024. All rights reserved.