lundi 22 août 2016

Python requests from amazon returns 403

Tried parsing a web page using python requests.Worked fine on local machine, returns 403 forbidden by administrative rules error in amazon s3 shell. Here is the code:

req_headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
'Accept': 'text/html,application/xhtml+xml,application/xml,application/json;q=0.9,*/*;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'Accept-Language': 'en-US,en;q=0.8',
'content-type': 'application/html',
'Connection': 'keep-alive'}
url = 'http://ift.tt/2c1hPOL'
url_req = requests.get(url, headers=req_headers)
url_req.status_code

What did I do wrong? Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire