Python 用美丽的汤刮网寻找动物
我正试图从搜索引擎网站上抓到一只狗 在我的例子中,它是波美拉尼亚的 我不确定汤里应该有什么。全部找到 这就是我所做的:Python 用美丽的汤刮网寻找动物,python,web-scraping,beautifulsoup,Python,Web Scraping,Beautifulsoup,我正试图从搜索引擎网站上抓到一只狗 在我的例子中,它是波美拉尼亚的 我不确定汤里应该有什么。全部找到 这就是我所做的: url=”https://www.winwin.co.il/Animals/Search/SearchResults/AnimalPage.aspx?search=f1b130870fcd32672a71e39ae8e26898" response=requests.get(url) data=response.text soup=BeautifulSoup(数据,'html.
url=”https://www.winwin.co.il/Animals/Search/SearchResults/AnimalPage.aspx?search=f1b130870fcd32672a71e39ae8e26898"
response=requests.get(url)
data=response.text
soup=BeautifulSoup(数据,'html.parser')
dog=soup.find_all(“div”,“class”:“ContainerSEOTxt”})
查找所有项的结果必须是项的数组
soup.find_all("a")
print output
[<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,
<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>,
<a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>]
如果有多个类名,只需将类名列表作为参数传递即可
divs = soup.find_all('div', ['class1', 'class2'])
find_all的结果必须是item的数组
soup.find_all("a")
print output
[<a class="sister" href="http://example.com/elsie" id="link1">Elsie</a>,
<a class="sister" href="http://example.com/lacie" id="link2">Lacie</a>,
<a class="sister" href="http://example.com/tillie" id="link3">Tillie</a>]
如果有多个类名,只需将类名列表作为参数传递即可
divs = soup.find_all('div', ['class1', 'class2'])
问题是什么?在旧版本中,我们使用findAll now find_all,check version tooBoris有下面的正确答案,同时为了节省空间,更容易添加以下内容:soup=beautifulsou(response.text,'html.parser')问题是什么?在旧版本中,我们使用findAll now find_all,check version tooBoris有下面的正确答案,另外,为了节省空间,添加以下内容更容易:soup=BeautifulSoup(response.text,'html.parser')