download by script

Hi,

I try to download ansible on this url :

url = http://ansibleworks.com/releases/ansible-1.4.tar.gz

with this python code :

url_obj = urllib2.urlopen(url)

and I systematically get this as return code :

HTTP Error 403: Forbidden

Does anyone understand why ?

Thank you

It could be the server is blocking your header to prevent web scrapping , try to change the default user-agent from the urlib header use Request.add_header

It could be the server is blocking your header to prevent web scrapping , try to change the default user-agent from the urlib header use Request.add_header

I changed my code to :

headers = {'User-agent': 'Mozilla/5.0',}
req = urllib2.Request(url, None, headers)
url_obj = urllib2.urlopen(req)

And it works, thanks !

glad that you solved it