Selenium Webdriver 无法访问网站(请求 URL 被拒绝)

Selenium Webdriver can't access a website (The requested URL was rejected)

我做了几个小时的研究,并在 fiverr 上问了一堆人,他们都无法解决我遇到的特定问题。

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

我尝试了几种方法,例如:

没有任何帮助。

这是我收到的错误的屏幕截图:



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

# 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>
    
  • 浏览器快照:


结论

Page Source 可以很明显地检测到 driven initiated Browsing Context 并且导航被阻止。

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


参考资料

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