Sometimes it's necessary to change the version
attribute when retrieving a request using FancyURLopener
, e.g.
from urllib.request import FancyURLopener
class NewOpener(FancyURLopener):
version = 'Some fancy thing'
url = 'www.google.com'
opener = NewOpener.retrieve(url, 'google.html')
Is there an equivalence in the requests
library when using requests.get()
?
As @Sraw commented, the "version" is basically the user-agent
file in the header, so
requests.get(url, headers={'User-agent': 'Some fancy thing'}