mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/unkn0w7n/calibre
This commit is contained in:
commit
43cb9c2fbb
@ -81,6 +81,22 @@ class WSJ(BasicNewsRecipe):
|
|||||||
div.extract()
|
div.extract()
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
def _download_cover(self):
|
||||||
|
import os
|
||||||
|
from calibre import browser
|
||||||
|
from contextlib import closing
|
||||||
|
from calibre.utils.img import add_borders_to_image, image_to_data, save_cover_data_to
|
||||||
|
br = browser()
|
||||||
|
raw = br.open('https://www.frontpages.com/the-wall-street-journal/')
|
||||||
|
soup = BeautifulSoup(raw.read())
|
||||||
|
cu = 'https://www.frontpages.com' + soup.find('img', attrs={'id':'giornale-img'})['src']
|
||||||
|
self.report_progress(1, _('Downloading cover from %s')%cu)
|
||||||
|
with closing(br.open(cu, timeout=self.timeout)) as r:
|
||||||
|
cdata = r.read()
|
||||||
|
cpath = os.path.join(self.output_dir, 'cover.jpg')
|
||||||
|
save_cover_data_to(cdata, cpath)
|
||||||
|
self.cover_path = cpath
|
||||||
|
|
||||||
def get_browser(self, *args, **kw):
|
def get_browser(self, *args, **kw):
|
||||||
kw['user_agent'] = 'okhttp/4.10.0'
|
kw['user_agent'] = 'okhttp/4.10.0'
|
||||||
br = BasicNewsRecipe.get_browser(self, *args, **kw)
|
br = BasicNewsRecipe.get_browser(self, *args, **kw)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user