mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Use an up-to-date UA when downloading news
This commit is contained in:
parent
e0ec185ea2
commit
0e19f6a399
@ -529,8 +529,8 @@ class BasicNewsRecipe(Recipe):
|
||||
'''
|
||||
if 'user_agent' not in kwargs:
|
||||
# More and more news sites are serving JPEG XR images to IE
|
||||
kwargs['user_agent'] = self.last_used_user_agent = getattr(
|
||||
self, 'last_used_user_agent', None) or random_user_agent(allow_ie=False)
|
||||
ua = getattr(self, 'last_used_user_agent', None) or self.calibre_most_common_ua or random_user_agent(allow_ie=False)
|
||||
kwargs['user_agent'] = self.last_used_user_agent = ua
|
||||
self.log('Using user agent:', kwargs['user_agent'])
|
||||
br = browser(*args, **kwargs)
|
||||
br.addheaders += [('Accept', '*/*')]
|
||||
|
@ -51,10 +51,12 @@ def compile_recipe(src):
|
||||
'xrange': range,
|
||||
}
|
||||
exec(src, namespace)
|
||||
ua = namespace.get('calibre_most_common_ua')
|
||||
|
||||
for x in itervalues(namespace):
|
||||
if (isinstance(x, type) and issubclass(x, BasicNewsRecipe) and x not
|
||||
in basic_recipes):
|
||||
x.calibre_most_common_ua = ua
|
||||
return x
|
||||
|
||||
return None
|
||||
|
Loading…
x
Reference in New Issue
Block a user