【问题标题】:Chrome browser initiated through ChromeDriver gets detected检测到通过 ChromeDriver 启动的 Chrome 浏览器
【发布时间】:2019-03-20 19:21:54
【问题描述】:

我正在尝试在 python 中为网站 www.mouser.co.uk 使用 selenium chromedriver。但是,从第一张照片开始,它就被检测为机器人。

有人对此有解释吗?此后我使用的代码:

options = Options()
options.add_argument("--start-maximized")
browser = webdriver.Chrome('chromedriver.exe',chrome_options=options)
wait = WebDriverWait(browser, 30)
browser.get('https://www.mouser.co.uk')

【问题讨论】:

标签: python selenium google-chrome selenium-webdriver selenium-chromedriver


【解决方案1】:

我尝试使用某些 chrome.options 访问 url https://www.mouser.co.uk/,但确实被检测到并被重定向到 Pardon Our Interruption 页面。

  • 代码块:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    options = Options()
    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.mouser.co.uk")
    myElement = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, "//a[@id='1_lnkLeftFlag']")))
    driver.execute_script("arguments[0].click();", myElement)
    

现在查看Pardon Our Interruption页面,您会发现<body>标签包含:

  • 属性dist-GlobalHeader
  • 属性dist-PageWrap

这清楚地表明该网站受到 Bot Management 服务提供商 Distil Networks 的保护,并且 ChromeDriver 的导航被检测到并随后被阻止强>。


蒸馏

根据文章There Really Is Something About 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".


参考

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

【讨论】:

  • 很好的根本原因分析。这真的很有帮助。
【解决方案2】:

尝试了这里建议的所有内容,但没有任何效果。只有这个模块对我有用:

https://github.com/ultrafunkamsterdam/undetected-chromedriver

我用它来获取一个有机器人检测的网站。我尝试在以前的答案中使用所有建议的方法,但没有成功。这个模块的使用非常简单,在 git repo 本身中有描述。

旁注:版主已多次删除此帖子的先前版本,恕我直言,没有充分的理由。我希望这次编辑能够通过。祝你好运。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-11-17
    • 1970-01-01
    • 2017-04-13
    • 2016-05-21
    • 1970-01-01
    • 1970-01-01
    • 2013-07-19
    • 1970-01-01
    相关资源
    最近更新 更多