I have a script I am working on that uses urllib2. I am trying to change the default “User-Agent” that is used because the backend is looking for a certain User-Agent. I am having no success. Below is the code I am using but it is not working to change the User-Agent. Any help is appreciated.
Code:
request = urllib2.Request(url, headers={"User-Agent" : "CUSTOM_USER_AGENT", "Accept" : "application/xml"})
u = urllib2.urlopen(request)
I can not figure out what I am doing wrong here…