【发布时间】:2020-05-03 07:36:36
【问题描述】:
我在 Yellowpages.com.au 上抓取公司名称,并且我了解如何找到正确的元素(div 类)来查找所有名称。 下面是我的 python 代码和我想抓取公司名称信息的 url。 每次,我运行这段代码,我什么都得不到。
``` import bs4
from bs4 import BeautifulSoup
import lxml
import requests
url='https://www.yellowpages.com.au/search/listings?clue=plywood&locationClue=Northern+Territory&lat=&lon='
response=requests.get(url)
print('ok')
soup=BeautifulSoup(response.text,'lxml')
page=soup.find_all('div', class_="body left")
print(page) ```
我已附上被检查网站/网址的图片。
【问题讨论】:
-
它可能是动态加载的页面,您可能要考虑使用
selenium。 -
XPATH 类似于
//a[@class="listing-name"]/text()。但我无法测试,我需要先通过验证码。 -
谢谢,我现在开始学习 selenium,但如果你能写代码给我,非常欢迎。
标签: python beautifulsoup python-requests lxml