mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More robust cover fetching for the economist
This commit is contained in:
parent
19b54b8008
commit
d26a9127a2
@ -55,12 +55,17 @@ class Economist(BasicNewsRecipe):
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
br = self.browser
|
soup = self.index_to_soup('http://www.economist.com/printedition/covers')
|
||||||
br.open(self.INDEX)
|
div = soup.find('div', attrs={'class':lambda x: x and
|
||||||
issue = br.geturl().split('/')[4]
|
'print-cover-links' in x})
|
||||||
self.log('Fetching cover for issue: %s'%issue)
|
a = div.find('a', href=True)
|
||||||
cover_url = "http://media.economist.com/sites/default/files/imagecache/print-cover-full/print-covers/%s_CNA400_0.jpg" %(issue.translate(None,'-'))
|
url = a.get('href')
|
||||||
return cover_url
|
if url.startswith('/'):
|
||||||
|
url = 'http://www.economist.com' + url
|
||||||
|
soup = self.index_to_soup(url)
|
||||||
|
div = soup.find('div', attrs={'class':'cover-content'})
|
||||||
|
img = div.find('img', src=True)
|
||||||
|
return img.get('src')
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
return self.economist_parse_index()
|
return self.economist_parse_index()
|
||||||
|
@ -39,13 +39,17 @@ class Economist(BasicNewsRecipe):
|
|||||||
delay = 1
|
delay = 1
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
br = self.browser
|
soup = self.index_to_soup('http://www.economist.com/printedition/covers')
|
||||||
br.open(self.INDEX)
|
div = soup.find('div', attrs={'class':lambda x: x and
|
||||||
issue = br.geturl().split('/')[4]
|
'print-cover-links' in x})
|
||||||
self.log('Fetching cover for issue: %s'%issue)
|
a = div.find('a', href=True)
|
||||||
cover_url = "http://media.economist.com/sites/default/files/imagecache/print-cover-full/print-covers/%s_CNA400_0.jpg" %(issue.translate(None,'-'))
|
url = a.get('href')
|
||||||
return cover_url
|
if url.startswith('/'):
|
||||||
|
url = 'http://www.economist.com' + url
|
||||||
|
soup = self.index_to_soup(url)
|
||||||
|
div = soup.find('div', attrs={'class':'cover-content'})
|
||||||
|
img = div.find('img', src=True)
|
||||||
|
return img.get('src')
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user