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

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

问题描述:

我正在尝试自动登录网页以下载每日xml.我了解我需要拥有我认为是的实际框架网址

I am trying to automate my login to a webpage to download a daily xml. I understand that I need to have the actual frame url I think is

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

ERR_TOO_MANY_REDIRECTS (also known as a redirect loop) is one of the regular website errors. 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.

使用 ERR_TOO_MANY_REDIRECTS 的原因是,某种原因导致您的网站进入无限重定向循环.本质上说,网站是卡住的(例如 URL 1 指向 URL 2 ,而 URL 2 指向回到 URL 1 ,或者网域将您重定向了太多次),并且与其他一些错误不同,这些错误很少能自行解决,因此可能需要您采取措施加以解决.根据您所运行的浏览器,此错误有几种不同的变化形式.

The reason for ERR_TOO_MANY_REDIRECTS is that, something is causing your website to go into an infinite redirection loop. 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. There are a couple different variations of this error depending upon the browser you’re running.

一些常见的检查和修复错误的方法,如下所示:

Some common approach to check and fix the error as as follows:

  • 在该特定网站上删除Cookie :实际上,Google和Mozilla都建议在错误的下方, 尝试清除您的cookie. cookie有时可能包含错误的数据,可能会导致ERR_TOO_MANY_REDIRECTS错误.即使您在自己不拥有的网站上遇到错误,也可以尝试使用此建议.由于Cookie会保留您在网站上的 登录 状态和其他设置,因此在这些情况下,只需删除出现问题的网站上的cookie.这样,您就不会影响您经常访问的任何其他会话或网站.
  • 清除浏览器缓存:如果要检查并查看是否可能作为您的浏览器缓存,而无需清除缓存,您始终可以以隐身模式打开浏览器.或测试其他浏览器,看看是否仍然看到 ERR_TOO_MANY_REDIRECTS 错误.
  • 确定重定向循环的性质:如果清除缓存无效,那么您将要查看是否可以确定重定向循环的性质.例如,如果站点具有返回到其自身的301重定向循环,则将导致大量的错误重定向链.您可以跟踪所有重定向,并确定其是否循环回到自身,或者是否是HTTP到HTTPS循环.
  • 检查您的HTTPS设置:要检查的另一件事是您的HTTPS设置.在很多情况下,有人将WordPress网站迁移到HTTPS并没有完成或设置不正确时,就会发生 ERR_TOO_MANY_REDIRECTS .
  • 检查第三方服务: ERR_TOO_MANY_REDIRECTS 代码>通常也通常是由反向代理服务(例如Cloudflare)引起的.当启用了其灵活SSL"选项并且您已经在WordPress主机上安装了SSL证书时,通常会发生这种情况.为什么?因为选择灵活时,所有对托管服务器的请求都会通过HTTP发送.您的主机服务器很可能已经从HTTP重定向到HTTPS,因此发生了重定向循环.
  • 检查服务器上的重定向:除了HTTP到HTTPS重定向外您的服务器,最好检查一下并确保没有其他任何重定向设置错误.例如,一个错误的301重定向回到自身可能会使您的网站瘫痪.通常,这些可以在您服务器的配置文件中找到.
  • Delete Cookies on That Specific Site: Google and Mozilla both in fact recommends right below the error to try clearing your cookies. Cookies can sometimes contain faulty data in which could cause the ERR_TOO_MANY_REDIRECTS error. 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. 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.
  • 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. You can follow all the redirects and determine whether or not its looping back to itself, or perhaps is an HTTP to HTTPS loop.
  • Check Your HTTPS Settings: Another thing to check is your HTTPS settings. 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.
  • Check Third-Party Services: ERR_TOO_MANY_REDIRECTS is also often commonly caused by reverse-proxy services such as Cloudflare. This usually happens when their Flexible SSL option is enabled and you already have an SSL certificate installed with your WordPress host. Why? Because, when flexible is selected, all requests to your hosting server are sent over HTTP. Your host server most likely already has a redirect in place from HTTP to HTTPS, and therefore a redirect loop occurs.
  • 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. For example, one bad 301 redirect back to itself could take down your site. Usually, these are found in your server’s config files.