检测到带有 chrome 驱动程序的 Python Selenium Web 驱动程序

ech*_*cho 4 python selenium

我假设 Selenium 打开的 chrome 浏览会话与 google chrome 本地安装相同。但是当我尝试在这个网站上搜索时,即使只是用 selenium 打开它并手动控制搜索过程,我也会收到一条错误消息,因为当我在自己的个人资料中或在隐身窗口中使用常规 chrome 时,搜索结果返回正常。每当我搜索这个问题时,我都会发现说明鼠标移动或点击模式的结果会泄露它。但事实并非如此,因为我在打开浏览器后尝试手动控制。html 请求中的某些内容将其泄露出去。有没有办法克服它?有问题的网站是:https : //www.avnet.com/wps/portal/us

自动会话中的错误消息。 在此处输入图片说明

Deb*_*anB 5

根据相关网站https://www.avnet.com/wps/portal/us,我不确定您面临的确切问题,也许您的代码块会给我们提供更多线索。但是我能够url很好地访问提到的:

代码块:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

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.avnet.com/wps/portal/us')
print("Page Title is : %s" %driver.title)
Run Code Online (Sandbox Code Playgroud)

控制台输出:

Page Title is : Avnet: Quality Electronic Components & Services
Run Code Online (Sandbox Code Playgroud)

快照:

Avnet:优质电子元件和服务


更新

我重新审视了您面临的问题。我已经阅读了整个HTML DOM并且没有发现任何机器人检测机制的痕迹。如果有任何机器人检测机制实现了该网站,甚至不会允许您遍历/抓取DOM 树甚至找到搜索框

进一步调试问题以下是我的观察:

  • 通过您的自动化脚本,您可以继续直到将搜索文本成功发送到搜索框

搜索框

  • 当您手动搜索有效产品时,自动建议通过<span>标签显示为下面的 html,您可以单击任何自动建议以浏览特定产品。

  • 汽车建议:

跨度是零件

  • SPAN 标签 HTML :

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

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.avnet.com/wps/portal/us')
print("Page Title is : %s" %driver.title)
Run Code Online (Sandbox Code Playgroud)

  • <span>当我们使用WebDriver时,这基本上不会被触发/生成。

spanTagNotTraggered

  • 如果您强制搜索结果进入错误页面,则没有自动建议

结论

主要问题似乎是表单控件类或与onkeydown事件关联的函数scrollDown(event,this)