【发布时间】:2021-08-04 07:56:17
【问题描述】:
我在尝试使用 python 和 Beautiful Soup 抓取详细信息时无法获取此网站中每个宠物的 div:https://indyhumane.org/adoptable-cats/
当我检查页面并检查 html 源代码时,我看到包含每个宠物配置文件的 div 带有 class = "mbcpp_result_animal",但是当我使用下面的代码时,@ 的长度为零987654325@
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,当我在 chrome 的开发人员工具中检查页面时,我看不到任何带有 class="mbcpp_result_animal" 的 div,这与 html 源代码不同。
这是我的第一次网络抓取。所以,我觉得我还没有完全理解这个过程。谁能告诉我我需要做什么来解决这个问题?
【问题讨论】:
标签: python html web-scraping beautifulsoup