mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Update wsj.recipe
fix cover-changed source
This commit is contained in:
parent
612aa3d81a
commit
5aa877f6dd
@ -164,20 +164,26 @@ class WSJ(BasicNewsRecipe):
|
||||
return soup
|
||||
|
||||
def _download_cover(self):
|
||||
d = self.recipe_specific_options.get('date')
|
||||
if not (d and isinstance(d, str)):
|
||||
import os
|
||||
from contextlib import closing
|
||||
|
||||
from calibre.utils.img import save_cover_data_to
|
||||
|
||||
br = browser()
|
||||
raw = br.open('https://www.frontpages.com/the-wall-street-journal/')
|
||||
dt = self.recipe_specific_options.get('date')
|
||||
if (dt and isinstance(dt, str)):
|
||||
d, m, y = dt.split('-')
|
||||
cu = f'https://www.wsj.com/public/resources/documents/WSJNewsPaper-{int(m)}-{int(d)}-{y}.jpg'
|
||||
else:
|
||||
raw = br.open('https://wsjtodaysedition.cmail19.com/t/d-e-suujjg-thithlkhlr-r/')
|
||||
soup = BeautifulSoup(raw.read())
|
||||
cu = (
|
||||
'https://www.frontpages.com'
|
||||
+ soup.find('img', attrs={'id': 'giornale-img'})['src']
|
||||
)
|
||||
cu = soup.find(
|
||||
'img',
|
||||
attrs={
|
||||
'class': 'responsive-img',
|
||||
'src': lambda x: x and 'WSJNewsPaper' in x
|
||||
}
|
||||
)['src']
|
||||
self.report_progress(1, _('Downloading cover from %s') % cu)
|
||||
with closing(br.open(cu, timeout=self.timeout)) as r:
|
||||
cdata = r.read()
|
||||
|
Loading…
x
Reference in New Issue
Block a user