简体   繁体   English

尝试通过使用 Selenium 和 Python 的框架和 Javascript 的网页登录时出现 ERR_TOO_MANY_REDIRECTS 错误

[英]ERR_TOO_MANY_REDIRECTS error while trying to login through a webpage that uses frames and Javascript using Selenium and Python

I am trying to automate my login to a webpage to download a daily xml.我正在尝试自动登录网页以下载每日 xml。 I understand that I need to have the actual frame url I think is我知道我需要有我认为的实际框架网址

http://shop.braintrust.gr/shop/store/customerauthenticateform.asp http://shop.braintrust.gr/shop/store/customerauthenticateform.asp

I examine the form and the fields and I do the following我检查表单和字段,然后执行以下操作

browser = webdriver.Chrome('C:\\chromedriver.exe')
browser.get('http://shop.braintrust.gr/shop/store/customerauthenticateform.asp')
print('Browser Opened')
username = browser.find_element_by_name('UserID')
username.send_keys(email)
password = browser.find_element_by_name('password')
# time.sleep(2)
password.send_keys(pwd)

but I get a blank page saying that browser did a lot of redirections this means that it is impossible to login?但是我得到一个空白页面,说浏览器做了很多重定向,这意味着无法登录? How can I login?如何登录? thank you谢谢你

ERR_TOO_MANY_REDIRECTS ERR_TOO_MANY_REDIRECTS

ERR_TOO_MANY_REDIRECTS (also known as a redirect loop) is one of the regular website errors. ERR_TOO_MANY_REDIRECTS (也称为重定向循环)是常见的网站错误之一。 Typically this error occurs after a recent change to your website, a mis-configuration of redirects on your server or wrong settings with third-party services.通常,此错误发生在最近更改您的网站、服务器上的重定向配置错误或第三方服务的错误设置之后。

This error have no relation with Selenium as such and can be reproduced through Manual Steps .此错误与Selenium本身无关,可以通过Manual Steps重现。

The reason for ERR_TOO_MANY_REDIRECTS is that, something is causing your website to go into an infinite redirection loop . ERR_TOO_MANY_REDIRECTS的原因是,某些原因导致您的网站进入无限重定向循环 Essentially the site is stuck (such as URL 1 points to URL 2 and URL 2 points back to URL 1 , or the domain has redirected you too many times) and unlike some other errors, these rarely resolve themselves and will probably need you to take action to fix it.本质上,该站点卡住了(例如URL 1指向URL 2并且URL 2指向URL 1 ,或者域已​​将您重定向太多次)并且与其他一些错误不同,这些错误很少会自行解决,可能需要您采取修复它的行动。 There are a couple different variations of this error depending upon the browser you're running.根据您运行的浏览器,此错误有几种不同的变体。


Solution解决方案

Some common approach to check and fix the error as as follows:一些常见的检查和修复错误的方法如下:

  • Delete Cookies on That Specific Site : Google and Mozilla both in fact recommends right below the error to try clearing your cookies. 删除特定站点上的 Cookie :实际上,Google 和 Mozilla 都建议在错误下方try clearing your cookies. Cookies can sometimes contain faulty data in which could cause the ERR_TOO_MANY_REDIRECTS error. Cookie 有时可能包含错误数据,其中可能导致 ERR_TOO_MANY_REDIRECTS 错误。 This is one recommendation you can try even if you're encountering the error on a site you don't own.这是一项建议,即使您在不属于您的网站上遇到错误,也可以尝试。 Due to the fact that cookies retain your logged in status on sites and other settings, in these cases simply deleting the cookie(s) on the site that is having the problem.由于 cookie 会保留您在站点上的登录状态和其他设置,在这些情况下,只需删除出现问题的站点上的 cookie。 This way you won't impact any of your other sessions or websites that you frequently visit.这样您就不会影响您经常访问的任何其他会话或网站。
  • Clear Browser Cache : If you want to check and see if it might be your browser cache, without clearing your cache, you can always open up your browser in incognito mode. 清除浏览器缓存:如果您想检查并查看它是否可能是您的浏览器缓存,而无需清除缓存,您可以随时以隐身模式打开浏览器。 Or test another browser and see if you still see the ERR_TOO_MANY_REDIRECTS error.或者测试另一个浏览器,看看你是否仍然看到ERR_TOO_MANY_REDIRECTS错误。
  • Determine Nature of Redirect Loop : If clearing the cache didn't work, then you'll want to see if you can determine the nature of the redirect loop. 确定重定向循环的性质:如果清除缓存不起作用,那么您将想看看是否可以确定重定向循环的性质。 For example, if a site has a 301 redirect loop back to itself, which is causing a large chain of faulty redirects.例如,如果一个站点有一个返回自身的 301 重定向循环,这会导致大量错误的重定向。 You can follow all the redirects and determine whether or not its looping back to itself, or perhaps is an HTTP to HTTPS loop.您可以跟踪所有重定向并确定其是否循环回到自身,或者可能是 HTTP 到 HTTPS 循环。
  • Check Your HTTPS Settings : Another thing to check is your HTTPS settings. 检查您的 HTTPS 设置:要检查的另一件事是您的 HTTPS 设置。 A lot of times it is observed ERR_TOO_MANY_REDIRECTS occur when someone has just migrated their WordPress site to HTTPS and either didn't finish or setup something incorrectly.很多时候,当有人刚刚将他们的 WordPress 站点迁移到 HTTPS 并且没有完成或设置不正确时,会观察到ERR_TOO_MANY_REDIRECTS发生。
  • Check Third-Party Services : ERR_TOO_MANY_REDIRECTS is also often commonly caused by reverse-proxy services such as Cloudflare. 检查第三方服务ERR_TOO_MANY_REDIRECTS也通常是由 Cloudflare 等反向代理服务引起的。 This usually happens when their Flexible SSL option is enabled and you already have an SSL certificate installed with your WordPress host.这通常发生在启用了灵活 SSL 选项并且您已经在 WordPress 主机上安装了 SSL 证书时。 Why?为什么? Because, when flexible is selected, all requests to your hosting server are sent over HTTP.因为选择灵活时,所有对托管服务器的请求都会通过HTTP发送。 Your host server most likely already has a redirect in place from HTTP to HTTPS, and therefore a redirect loop occurs.您的主机服务器很可能已经进行了从 HTTP 到 HTTPS 的重定向,因此会发生重定向循环。
  • Check Redirects on Your Server : Besides HTTP to HTTPS redirects on your server, it can be good to check and make sure there aren't any additional redirects setup wrong. 检查服务器上的重定向:除了服务器上的HTTP 到 HTTPS 重定向之外,最好检查并确保没有任何其他重定向设置错误。 For example, one bad 301 redirect back to itself could take down your site.例如,一个错误的 301 重定向回自身可能会关闭您的网站。 Usually, these are found in your server's config files.通常,这些可以在服务器的配置文件中找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM