Update wsj.recipe

fix cover-changed source
This commit is contained in:
unkn0w7n 2025-07-27 11:07:14 +05:30
parent 612aa3d81a
commit 5aa877f6dd

View File

@ -164,20 +164,26 @@ class WSJ(BasicNewsRecipe):
return soup return soup
def _download_cover(self): def _download_cover(self):
d = self.recipe_specific_options.get('date')
if not (d and isinstance(d, str)):
import os import os
from contextlib import closing from contextlib import closing
from calibre.utils.img import save_cover_data_to from calibre.utils.img import save_cover_data_to
br = browser() 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()) soup = BeautifulSoup(raw.read())
cu = ( cu = soup.find(
'https://www.frontpages.com' 'img',
+ soup.find('img', attrs={'id': 'giornale-img'})['src'] attrs={
) 'class': 'responsive-img',
'src': lambda x: x and 'WSJNewsPaper' in x
}
)['src']
self.report_progress(1, _('Downloading cover from %s') % cu) self.report_progress(1, _('Downloading cover from %s') % cu)
with closing(br.open(cu, timeout=self.timeout)) as r: with closing(br.open(cu, timeout=self.timeout)) as r:
cdata = r.read() cdata = r.read()