Log the user agent and keep it stable

This commit is contained in:
Kovid Goyal 2019-12-06 14:01:08 +05:30
parent 2e693b4156
commit 2d25f8d779
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -502,7 +502,9 @@ class BasicNewsRecipe(Recipe):
'''
if 'user_agent' not in kwargs:
# More and more news sites are serving JPEG XR images to IE
kwargs['user_agent'] = random_user_agent(allow_ie=False)
kwargs['user_agent'] = self.last_used_user_agent = getattr(
self, 'last_used_user_agent', None) or random_user_agent(allow_ie=False)
self.log('Using user agent:', kwargs['user_agent'])
br = browser(*args, **kwargs)
br.addheaders += [('Accept', '*/*')]
if self.handle_gzip: