Economist: handle printedition page redirecting to previous issue instead of current one

This commit is contained in:
Kovid Goyal 2018-11-16 12:24:41 +05:30
parent 1026635639
commit 97f9373a99
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 0 deletions

View File

@ -167,6 +167,12 @@ class Economist(BasicNewsRecipe):
# with open('/t/raw.html', 'wb') as f: # with open('/t/raw.html', 'wb') as f:
# f.write(raw) # f.write(raw)
soup = self.index_to_soup(raw) soup = self.index_to_soup(raw)
nav = soup.find(attrs={'class':'navigation__wrapper'})
if nav is not None:
a = nav.find('a', href=lambda x: x and '/printedition/' in x)
if a is not None:
self.log('Following nav link to current edition', a['href'])
soup = self.index_to_soup(process_url(a['href']))
ans = self.economist_parse_index(soup) ans = self.economist_parse_index(soup)
if not ans: if not ans:
raise NoArticles( raise NoArticles(

View File

@ -167,6 +167,12 @@ class Economist(BasicNewsRecipe):
# with open('/t/raw.html', 'wb') as f: # with open('/t/raw.html', 'wb') as f:
# f.write(raw) # f.write(raw)
soup = self.index_to_soup(raw) soup = self.index_to_soup(raw)
nav = soup.find(attrs={'class':'navigation__wrapper'})
if nav is not None:
a = nav.find('a', href=lambda x: x and '/printedition/' in x)
if a is not None:
self.log('Following nav link to current edition', a['href'])
soup = self.index_to_soup(process_url(a['href']))
ans = self.economist_parse_index(soup) ans = self.economist_parse_index(soup)
if not ans: if not ans:
raise NoArticles( raise NoArticles(