“该网站的所有者已根据您浏览器的签名禁止您访问”...在python程序中的url请求中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24913699/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"The owner of this website has banned your access based on your browser's signature" ... on a url request in a python program
提问by BERNARD Julien
When doing a simple request, on python (Entought Canopy to be precise), with urllib2, the server denies me access :
在使用 urllib2 执行简单请求时,在 python(准确地说是 Entought Canopy)上,服务器拒绝我访问:
data = urllib.urlopen(an url i cannot post because of reputation, params)
print data.read()
Error:
错误:
Access denied | play.pokemonshowdown.com used CloudFlare to restrict access
The owner of this website (play.pokemonshowdown.com) has banned your access based on your browser's signature (14e894f5bf8d0920-ua48).
This is a apparently a generic issue, so I found several clues on the web.
这显然是一个通用问题,所以我在网上找到了一些线索。
A firewall, proxy, a browser plugin or extension may be throwing a false positive. Try visiting the site with a different browser as an alternative way of accessing the site.
防火墙、代理、浏览器插件或扩展程序可能会误报。尝试使用不同的浏览器访问该站点作为访问该站点的替代方式。
The "Checking your browser before accessing (insertsite.com) occurs when the site owner has turned on a DDoS protection and mitigation tool called "I'm Under Attack". The page will generally go away and grant you access to the site after 5 seconds.
Note: You will need to have both JavaScript and Cookies turned on in your browser to pass the check. The check is in place to make sure that you are not part of a botnet."
当站点所有者打开名为“我受到攻击”的 DDoS 保护和缓解工具时,会出现“在访问 (insertsite.com) 之前检查您的浏览器”。该页面通常会在 5 点后消失并授予您访问该站点的权限秒。
注意:您需要在浏览器中同时打开 JavaScript 和 Cookies 才能通过检查。检查已到位,以确保您不是僵尸网络的一部分。”
The answers are rather clear, except for this one thing ... *I'm not using any browser! The request is done trough a python program, with an urllib.urlopen
request ...
答案很清楚,除了这一件事...... *我没有使用任何浏览器!请求是通过 python 程序完成的,urllib.urlopen
请求...
Does this mean I'm supposed to have, like, cookies and JavaScript turned on in ... Enthought Canopy? Does this sentence makes any sentence at all? I barely understand anything about this browser specific check activating when trying to access the site with a basic request from a programming console. And that's why I ask for your help.
这是否意味着我应该在 ... Enthought Canopy 中打开 cookie 和 JavaScript?这句话是否构成任何句子?当我试图通过来自编程控制台的基本请求访问该站点时,我几乎不了解有关此浏览器特定检查激活的任何信息。这就是为什么我请求你的帮助。
Why does it happen? How to bypass it?
为什么会发生?如何绕过它?
采纳答案by bruno desthuilliers
What this site is "checking" is not your browser, it's the "user agent" - a string your client program (browser, Python script or whatever) eventuallysends as a request header. You can specify another user agent, cf Changing user agent on urllib2.urlopen.
该站点“检查”的不是您的浏览器,而是“用户代理”——您的客户端程序(浏览器、Python 脚本或其他任何东西)最终作为请求标头发送的字符串。您可以指定另一个用户代理,参见在 urllib2.urlopen 上更改用户代理。