Update Financial Times

This commit is contained in:
Kovid Goyal 2022-08-31 20:45:21 +05:30
parent 3f013c3856
commit 95b2e521c4
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 34 additions and 14 deletions

View File

@ -21,13 +21,23 @@ class ft(BasicNewsRecipe):
extra_css = '#fig-cap{font-style:italic; text-align:left; font-size:small;}' extra_css = '#fig-cap{font-style:italic; text-align:left; font-size:small;}'
def get_cover_url(self): def get_cover_url(self):
soup = self.index_to_soup( from datetime import date
'https://www.todayspapers.co.uk/the-financial-times-front-page-today/' cover = 'http://img.kiosko.net/' + str(
) date.today().year
tag = soup.find('div', attrs={'class': 'elementor-image'}) ) + '/' + date.today().strftime('%m') + '/' + date.today(
if tag: ).strftime('%d') + '/uk/ft_uk.750.jpg'
self.cover_url = tag.find('img')['src'] br = BasicNewsRecipe.get_browser(self)
return getattr(self, 'cover_url', self.cover_url) try:
br.open(cover)
except:
index = 'https://en.kiosko.net/uk/np/ft_uk.html'
soup = self.index_to_soup(index)
for image in soup.findAll('img', src=True):
if image['src'].endswith('750.jpg'):
return image['src']
self.log("\nCover unavailable")
cover = None
return cover
feeds = [ feeds = [
('World', 'https://www.ft.com/world?format=rss'), ('World', 'https://www.ft.com/world?format=rss'),

View File

@ -19,13 +19,23 @@ class ft(BasicNewsRecipe):
extra_css = '#fig-cap{font-style:italic; text-align:left; font-size:small;}' extra_css = '#fig-cap{font-style:italic; text-align:left; font-size:small;}'
def get_cover_url(self): def get_cover_url(self):
soup = self.index_to_soup( from datetime import date
'https://www.todayspapers.co.uk/the-financial-times-front-page-today/' cover = 'http://img.kiosko.net/' + str(
) date.today().year
tag = soup.find('div', attrs={'class': 'elementor-image'}) ) + '/' + date.today().strftime('%m') + '/' + date.today(
if tag: ).strftime('%d') + '/uk/ft_uk.750.jpg'
self.cover_url = tag.find('img')['src'] br = BasicNewsRecipe.get_browser(self)
return getattr(self, 'cover_url', self.cover_url) try:
br.open(cover)
except:
index = 'https://en.kiosko.net/uk/np/ft_uk.html'
soup = self.index_to_soup(index)
for image in soup.findAll('img', src=True):
if image['src'].endswith('750.jpg'):
return image['src']
self.log("\nCover unavailable")
cover = None
return cover
def parse_index(self): def parse_index(self):
soup = self.index_to_soup('https://www.ft.com/todaysnewspaper/uk') soup = self.index_to_soup('https://www.ft.com/todaysnewspaper/uk')