mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-08 19:13:40 +02:00
Use an up-to-date UA when downloading news
This commit is contained in:
parent
e0ec185ea2
commit
0e19f6a399
2 changed files with 4 additions and 2 deletions
|
|
@ -529,8 +529,8 @@ def get_browser(self):
|
|||
'''
|
||||
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…
Reference in a new issue