https://www.realestate.com.au/不允许网页抓取?



我试图从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("your link")

api - https://selenium-python.readthedocs.io/api.html?highlight=get#:~:text=ef_driver.get(%22http%3A//www.google.co.in/%22)

我确实尝试过通过selenium访问realestate.com.au,并在不同的用例中通过scrapy访问。通过使用适当的user-agent,我甚至得到了scrapy爬行的结果饼干和但几天后realestate.com.au检测到selenium/scrapy并阻止请求。

此外,如果在他们的条款中清楚地写着&严格禁止在其网站上索引任何内容的条件。

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

  1. 通过ChromeDriver启动的Chrome浏览器被检测到
  2. selenium没有加载页面

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

最新更新