Python Selenium Webdriver可以';无法访问网站(请求的URL被拒绝)

Python Selenium Webdriver可以';无法访问网站(请求的URL被拒绝),python,selenium,webdriver,selenium-chromedriver,bots,google-chrome,Python,Selenium,Webdriver,Selenium Chromedriver,Bots,Google Chrome,我做了几个小时的研究,问了五楼的一群人,他们都不能解决我遇到的一个具体问题 我安装了Selenium并尝试访问一个网站。不幸的是,该站点不允许特定的请求,并且根本不加载该站点。然而,如果我尝试使用我的“普通”Chrome浏览器访问该网站,它可以正常工作 我尝试了以下几种方法: 不同的IP 删除Cookies 隐姓埋名模式 添加不同的用户代理 隐藏可能显示正在使用Webdriver的功能 没有任何帮助 以下是我收到的错误截图: 下面是我正在使用的非常简单的脚本: # coding: ut

我做了几个小时的研究,问了五楼的一群人,他们都不能解决我遇到的一个具体问题

我安装了Selenium并尝试访问一个网站。不幸的是,该站点不允许特定的请求,并且根本不加载该站点。然而,如果我尝试使用我的“普通”Chrome浏览器访问该网站,它可以正常工作

我尝试了以下几种方法:

  • 不同的IP
  • 删除Cookies
  • 隐姓埋名模式
  • 添加不同的用户代理
  • 隐藏可能显示正在使用Webdriver的功能
没有任何帮助

以下是我收到的错误截图:



下面是我正在使用的非常简单的脚本:

# coding: utf8
from selenium import webdriver

url = 'https://registrierung.gmx.net/'

# Open ChromeDriver
driver = webdriver.Chrome();
# Open URL
driver.get(url)
如果有人能解决这个问题,我将不胜感激。 如果有人能帮我的话,我也愿意给你一大笔小费

非常感谢!
请大家保持健康。

我用几个参数修改了您的代码,并执行了测试。以下是观察结果:

  • 代码块:

    from selenium import webdriver
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    options.add_experimental_option("excludeSwitches", ["enable-automation"])
    options.add_experimental_option('useAutomationExtension', False)
    driver = webdriver.Chrome(options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    driver.get("https://registrierung.gmx.net/")
    print(driver.page_source)
    
  • 控制台输出:

    <html style="" class=" adownload applicationcache blobconstructor blob-constructor borderimage borderradius boxshadow boxsizing canvas canvastext checked classlist contenteditable no-contentsecuritypolicy no-contextmenu cors cssanimations csscalc csscolumns cssfilters cssgradients cssmask csspointerevents cssreflections cssremunit cssresize csstransforms3d csstransforms csstransitions cssvhunit cssvmaxunit cssvminunit cssvwunit dataset details deviceorientation displaytable display-table draganddrop fileinput filereader filesystem flexbox fullscreen geolocation getusermedia hashchange history hsla indexeddb inlinesvg json lastchild localstorage no-mathml mediaqueries meter multiplebgs notification objectfit object-fit opacity pagevisibility performance postmessage progressbar no-regions requestanimationframe raf rgba ruby scriptasync scriptdefer sharedworkers siblinggeneral smil no-strictmode no-stylescoped supports svg svgfilters textshadow no-time no-touchevents typedarrays userselect webaudio webgl websockets websqldatabase webworkers datalistelem video svgasimg datauri no-csshyphens"><head>
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="CacheControl" content="no-cache">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="shortcut icon" href="data:;base64,iVBORw0KGgo=">
    
    <script type="text/javascript">
    (function(){
    window["bobcmn"] = "10111111111010200000005200000005200000006200000001249d50ae8200000096200000000200000002300000000300000000300000006/TSPD/300000008TSPD_10130000000cTSPD_101_DID300000005https3000000b0082f871fb6ab200097a0a5b9e04f342a8fdfa6e9e63434256f3f63e9b3885e118fdacf66cc0a382208ea9dc3b70a28002d902f95eb5ac2e5d23ffe409bb24b4c57f9cb8e1a5db4bcad517230d966c75d327f561cc49e16f4300000002TS200000000200000000";
    .
    .
    <script type="text/javascript" src="/TSPD/082f871fb6ab20009afc88ee053e87fea57bf47d9659e73d0ea3c46c77969984660358739f3d19d0?type=11"></script>
    
    <script type="text/javascript">
    (function(){
    window["blobfp"] = "01010101b00400000100e803000000000d4200623938653464333234383463633839323030356632343563393735363433343663666464633135393536643461353031366131633362353762643466626238663337210068747470733a2f2f72652e73656375726974792e66356161732e636f6d2f72652f0700545350445f3734";window["slobfp"] = "08c3194e510b10009a08af8b7ee6860a22b5726420e697e4";
    
    
    })();
    
    </script>
    
    <script type="text/javascript" src="/TSPD/082f871fb6ab20009afc88ee053e87fea57bf47d9659e73d0ea3c46c77969984660358739f3d19d0?type=12"></script>
    <noscript>Please enable JavaScript to view the page content.<br/>Your support ID is: 11993951574422772310.</noscript>
    </head><body>
    <style>canvas {display:none;}</style><canvas width="800" height="600"></canvas></body></html>
    
    
    (功能(){
    窗口[“bobcmn”]="1011111101020000000520000000005200000062000000001249D50AE82000009620000000002000002300000000030000000066/TSPD/3000000008TSPD-U 10130000000cTSPD-U 101-DID000005HTTPS3000000B0082F87FB6AB00097A0A5B9E04F342A8FDFA6E9E63434256F3F63E9B3885E118FDACF66CC0A382208EA9DC3B70A28002D902FEB955AC2F85D23FFE40BB24C57CB8A58A53DB757C7CC49E16F430000002TS2000000000”;
    .
    .
    (功能(){
    窗口[“blobfp”]=“01010101B0040000100E80000000000D4200623836534643332343636338393230303563636339353433343663666463313535366434613530313661316333623562366264646366623866333721007470733A2F2F72652E736563757269792E663561732E636F6D6D2F72F72652F00700545045F3734”;窗口[“SLOBFP10083194E5603636366363636363647E672B7E727E492B”]=“194E520E520B16060AF767E497B7E492B";
    })();
    请启用JavaScript以查看页面内容。
    您的支持ID是:11993951574422772310。 画布{显示:无;}
  • 浏览器快照:


结论 从页面来源可以很清楚地看到,驱动启动的浏览上下文被检测到,导航被阻止

我本可以深入挖掘并提供更多见解,但令人惊讶的是,即使是手动,我现在也无法访问。可能我的IP现在已被列入黑名单。一旦我的IP被列入白名单,我将提供更多详细信息


工具书类 您可以在以下内容中找到一些相关的详细讨论:


当然可以!您帮助我缩小了请求错误的范围,这非常有帮助。您是否知道是否有可能绕过该错误并“隐藏”为了通过Webdriver正常访问网站,需要特定的浏览上下文,或者这不可能吗?正如我已经提到的,我的IP似乎被阻止了,因此我无法继续,我不想冒险现在通过后门将我的IP列入白名单。请通过参考讨论,这将提供更多类似的insi好的,可以:)谢谢again@nonskill很高兴能够帮助您。您发现这对未来读者的利益很有帮助。请参阅。