【问题标题】:https://www.realestate.com.au/ not permitting web scraping?https://www.realestate.com.au/ 不允许网页抓取?
【发布时间】:2021-11-03 06:48:06
【问题描述】:

我正在尝试从https://www.realestate.com.au/ 中提取数据 首先,我根据我正在寻找的属性类型创建我的 url,然后我使用 selenium webdriver 打开 url,但页面是空白的! 知道为什么会这样吗?是不是因为这个网站不提供网页抓取权限?有什么方法可以抓取这个网站吗?

这是我的代码:

from selenium import webdriver
from bs4 import BeautifulSoup
import time

PostCode = "2153"
propertyType = "house"
minBedrooms = "3"
maxBedrooms = "4"
page = "1"

url = "https://www.realestate.com.au/sold/property-{p}-with-{mib}-bedrooms-in-{po}/list-{pa}?maxBeds={mab}&includeSurrounding=false".format(p = propertyType, mib = minBedrooms, po = PostCode, pa = page, mab = maxBedrooms)
print(url)
# url should be "https://www.realestate.com.au/sold/property-house-with-3-bedrooms-in-2153/list-1?maxBeds=4&includeSurrounding=false"

driver = webdriver.Edge("./msedgedriver.exe") # edit the address to where your driver is located
driver.get(url)
time.sleep(3)

src = driver.page_source
soup = BeautifulSoup(src, 'html.parser')
print(soup)

【问题讨论】:

  • driver.get(url) 这不会在 UI 中显示任何数据?您也尝试过使用 chrome 驱动程序吗?
  • 查看robots.txt,他们禁止自动访问他们的网站
  • 感谢@cruisepandey 的回复。我认为不同的驱动程序无法解决此问题。正如 Rustam 指出的那样,他们严格禁止任何自动访问:(

标签: python selenium web-scraping


【解决方案1】:

【讨论】:

  • 谢谢 Vadim,我想知道您为什么认为它不正确吗?即使我将链接直接放入 .get() 函数中,它仍然没有给我任何东西。
  • 我直接从浏览器复制并粘贴链接。
  • 这里是链接。请尝试告诉我你的情况realestate.com.au/sold/…
【解决方案2】:

我确实尝试通过 selenium 访问 realestate.com.au,并通过 scrapy 在不同的用例中访问。 我什至通过使用正确的 user-agentcookie 获得了 scrapy 抓取的结果,但几天后 realestate.com.au 检测到 selenium / scrapy 并阻止了请求。

此外,他们的条款和条件中明确写明严格禁止将其网站中的任何内容编入索引。

您可以在这些问题中找到更多信息/分析:

  1. Chrome browser initiated through ChromeDriver gets detected
  2. selenium isn't loading the page

底线是,如果你想抓取内容,你必须超越他们的安全。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-30
    • 2020-06-18
    • 2018-04-12
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 2021-11-08
    相关资源
    最近更新 更多