我很难在这个网站上找到每只宠物的div
:https://indyhumane.org/adoptable-cats/同时尝试使用python和Beautiful Soup来获取细节
当我检查页面并检查html源代码时,我看到包含每个pet配置文件的div
带有一个class = "mbcpp_result_animal"
,但是当我使用下面的代码时,containers
的长度为零
from urllib.request import urlopen as uReq
from bs4 import BeautifulSoup as soup
my_url = 'https://indyhumane.org/adoptable-cats/'
uClient = uReq(my_url)
page_html = uClient.read()
uClient.close()
page_soup = soup(page_html, "html.parser")
containers = page_soup.findAll("div",{"class":"mbcpp_result_animal"})
print(len(containers))
如果我打印page_soup.body
,我看不到任何带有class="mbcpp_result_animal"
的div,这与我在chrome的开发工具中检查页面时的html源代码不同
这是我第一次刮网。所以,我觉得我还没有完全理解这个过程。有人能告诉我需要做什么来解决这个问题吗
因为这来自页面为检索结果和更新页面而进行的附加API调用。该调用具有querystring参数,您可以看到如下所示
它包括API端点、一个API键、限制搜索的条件和一个最终的随机数参数,可能是为了避免缓存结果。你可以引入一个实际的随机数
相关问题 更多 >
编程相关推荐