Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python requests <Response [520]>

I wrote this simple python code:

>>> import requests
>>> r = requests.get("http://prnt.sc/")
>>> r.status_code
520

i want to download the page at "http://prnt.sc/" and i can visualize it correctly using my browser (Mozilla) but with python i really can't.

I already tried changing and randomising my User-Agent using a python module named fake_useragent, but nothing changes.

I think this problem may be caused by the fact that python takes a different traceroute than my browser.

If I print r.text i get a cloudflare standard page error.

like image 285
Liam Avatar asked Apr 25 '17 16:04

Liam


1 Answers

Including a real User-Agent solved it for me:

>>> requests.get("http://prnt.sc/", headers={'User-Agent': 'Mozilla/5.0 (Platform; Security; OS-or-CPU; Localization; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)'}).status_code
200
like image 68
VMRuiz Avatar answered Oct 04 '22 20:10

VMRuiz