Selenium webdriver不会打开正确的url,而是打开一个空白页面

2024-09-21 03:05:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用selenium webdriver尝试从realestate.com.au中获取信息,以下是我的代码:

从selenium.webdriver导入Chrome 从bs4导入BeautifulSoup

path = 'C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe'
url = 'https://www.realestate.com.au/buy'
url2 = 'https://www.realestate.com.au/property-house-nsw-castle+hill-134181706'
webdriver = Chrome(path)
webdriver.get(url)
soup = BeautifulSoup(webdriver.page_source, 'html.parser')
print(soup)

它可以很好地处理URL,但当我尝试以同样的方式打开url2时,它会打开一个空白页面,我检查了控制台并获得以下信息: “加载资源失败:服务器响应状态为429() 关于:空白:1未能加载资源:net::ERR\u未知\u URL\u方案 149e9513-01fa-4fb0-aad4-566afd725d1b/2d206a39-8ed7-437e-a3be-862E06EEA3/指纹:1未能加载资源:服务器以404()的状态响应。“

在打开URL时,我尝试搜索任何内容,这也会导致出现一个类似url2的空白页面


Tags: pathhttpscomurlwwwselenium资源chrome
2条回答

我认为您应该尝试在get行之前添加driver.implicitly_wait(10),因为这将添加一个隐式等待,以防页面加载太慢,驱动程序无法拉动站点。此外,你应该考虑试用Firefox WebDebug,因为这个bug似乎只影响铬浏览器。

看起来www.realestate.com.au网站正在使用Akamai安全工具

快速DNS查找显示www.realestate.com.au解析为dualstack.realstate.com.au.edgekey.net

他们最有可能使用Bot管理器产品(https://www.akamai.com/us/en/products/security/bot-manager.jsp)。我最近在另一个网站上遇到过这种情况

通常轮换用户代理和IP地址(理想情况下使用住宅 代理)应该起作用。您希望每次加载带有“新”浏览器配置文件的站点。您还应该签出https://github.com/67-6f-64/akamai-sensor-data-bypass

相关问题 更多 >

    热门问题