python retrieve xml acting like a web browser [duplicate]




This question already has an answer here:




I want to make a url request to get an xml page using python.


When i use the



urllib2.Request(myurl)


I got 403 forbidden


When i use



webbrowser.open(myurl)


I can open the url in my browser.


I have learned from a java coder that he used the code below in java to make the program look like a browser so the program could retrieve the xml file without being blocked by the server.



resource.getClientInfo().setAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:25.0) Gecko/20100101 Firefox/25.0");


I am wondering if python can do something similar and if so where can I find the resources.


No comments:

Post a Comment