"The owner of this website has banned your access based on your browser's signature" ... on a url request in a python program

BERNARD Julien picture BERNARD Julien · Jul 23, 2014 · Viewed 24.6k times · Source

When doing a simple request, on python (Entought Canopy to be precise), with urllib2, the server denies me access :

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.

https://support.cloudflare.com/hc/en-us/articles/200171806-Error-1010-The-owner-of-this-website-has-banned-your-access-based-on-your-browser-s-signature:

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.

https://support.cloudflare.com/hc/en-us/articles/200170176-Why-am-I-getting-a-Checking-your-Browser-before-accessing-message-before-entering-a-site-on-CloudFlare-:

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."

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 ...

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.

Why does it happen? How to bypass it?

Answer

bruno desthuilliers picture bruno desthuilliers · Jul 23, 2014

What this site is "checking" is not your browser, it's the "user agent" - a string your client program (browser, Python script or whatever) eventually sends as a request header. You can specify another user agent, cf Changing user agent on urllib2.urlopen.