【问题标题】:how to get company name in this html using python web scraping?如何使用 python web 抓取在这个 html 中获取公司名称?
【发布时间】: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


【解决方案1】:

或许可以考虑以下免费 API

http://developers.sensis.com.au/docs/endpoint_reference

来自:

http://developers.sensis.com.au/

参见服务条款:

http://developers.sensis.com.au/Terms_of_Service

他们维护着大量黄色和白色的 AU 企业列表。 API 端点包括search。

http://developers.sensis.com.au/docs/endpoint_reference/Search

规格摘要:

https://www.programmableweb.com/api/sensis-business-search-rest-api

从文档中看起来相当简单。您需要注册一个 API 密钥。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-11
    • 2021-08-02
    • 2019-06-03
    • 2013-08-01
    • 1970-01-01
    • 2016-09-27
    • 1970-01-01
    • 2021-04-08
    相关资源
    最近更新 更多