网页正在使用 Chromedriver 作为机器人检测 Selenium Webdriver

Ale*_*lex 11 python selenium bots webdriver selenium-webdriver

我正在尝试使用 python抓取https://www.controller.com/,并且由于该页面检测到使用 bot 的机器人pandas.get_html,并且使用用户代理和旋转代理进行请求,因此我求助于使用 selenium webdriver。但是,这也被检测为带有以下消息的机器人。任何人都可以解释我怎样才能克服这个问题?:

请原谅我们的打扰... 当您浏览 www.controller.com 时,您的浏览器的某些方面让我们认为您是一个机器人。发生这种情况的原因有以下几个: 您是一名超级用户,以超人的速度浏览此网站。您已在 Web 浏览器中禁用 JavaScript。第三方浏览器插件(例如 Ghostery 或 NoScript)阻止 JavaScript 运行。此支持文章中提供了其他信息。要请求解锁,请填写下面的表格,我们会尽快审核”

这是我的代码:

from selenium import webdriver
import requests
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
options = webdriver.ChromeOptions()
options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument("disable-infobars")
options.add_argument("--disable-extensions")
#options.add_argument('headless')
driver = webdriver.Chrome(chrome_options=options)
driver.get('https://www.controller.com/')
driver.implicitly_wait(30)
Run Code Online (Sandbox Code Playgroud)

Deb*_*anB 14

pandas.get_html仅在您的问题和options.add_argument('headless')代码中提到过,因此不确定您是否正在实施它们。但是,从您的代码尝试中取出最少的代码如下:

  • 代码块:

    from selenium import webdriver
    
    options = webdriver.ChromeOptions()
    options.add_argument("start-maximized")
    options.add_argument("disable-infobars")
    options.add_argument("--disable-extensions")
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
    driver.get('https://www.controller.com/')
    print(driver.title)
    
    Run Code Online (Sandbox Code Playgroud)

我遇到了同样的问题。

  • 浏览器快照:

控制器_com

当我检查了HTML DOM有人指出,网站所引用的distil_referrerwindow.onbeforeunload,如下所示:

<script type="text/javascript" id="">
    window.onbeforeunload=function(a){"undefined"!==typeof sessionStorage&&sessionStorage.removeItem("distil_referrer")};
</script>
Run Code Online (Sandbox Code Playgroud)

快照:

卸载前

这清楚地表明该网站受到机器人管理服务提供商Distil Networks 的保护,ChromeDriver的导航被检测到并随后被阻止


蒸馏

根据文章确实有一些关于 Distil.it...

Distil 通过观察站点行为和识别爬虫特有的模式来保护站点免受自动内容爬取机器人的侵害。当 Distil 在一个站点上识别出恶意机器人时,它会创建一个列入黑名单的行为配置文件,并将其部署给所有客户。类似于机器人防火墙,Distil 检测模式并做出反应。

更远,

"One pattern with Selenium was automating the theft of Web content",Distil 首席执行官 Rami Essaid 上周在接受采访时表示。 "Even though they can create new bots, we figured out a way to identify Selenium the a tool they're using, so we're blocking Selenium no matter how many times they iterate on that bot. We're doing that now with Python and a lot of different technologies. Once we see a pattern emerge from one type of bot, then we work to reverse engineer the technology they use and identify it as malicious".


参考

您可以在以下位置找到一些详细的讨论:


归档时间:

查看次数:

30883 次

最近记录:

4 年,8 月 前