Fix Financial Times (UK)

This commit is contained in:
Kovid Goyal 2012-09-02 09:37:42 +05:30
parent 9360c5833a
commit a4b1689901

View File

@ -10,7 +10,7 @@ from calibre import strftime
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class FinancialTimes(BasicNewsRecipe): class FinancialTimes(BasicNewsRecipe):
title = 'Financial Times - UK printed edition' title = 'Financial Times (UK)'
__author__ = 'Darko Miletic' __author__ = 'Darko Miletic'
description = "The Financial Times (FT) is one of the world's leading business news and information organisations, recognised internationally for its authority, integrity and accuracy." description = "The Financial Times (FT) is one of the world's leading business news and information organisations, recognised internationally for its authority, integrity and accuracy."
publisher = 'The Financial Times Ltd.' publisher = 'The Financial Times Ltd.'
@ -101,17 +101,19 @@ class FinancialTimes(BasicNewsRecipe):
def parse_index(self): def parse_index(self):
feeds = [] feeds = []
soup = self.index_to_soup(self.INDEX) soup = self.index_to_soup(self.INDEX)
dates= self.tag_to_string(soup.find('div', attrs={'class':'btm-links'}).find('div'))
self.timefmt = ' [%s]'%dates
wide = soup.find('div',attrs={'class':'wide'}) wide = soup.find('div',attrs={'class':'wide'})
if not wide: if not wide:
return feeds return feeds
strest = wide.findAll('h3', attrs={'class':'section'}) strest = wide.findAll('h3', attrs={'class':'section'})
if not strest: if not strest:
return feeds return feeds
st = wide.find('h4',attrs={'class':'section-no-arrow'}) st = wide.findAll('h4',attrs={'class':'section-no-arrow'})
if st: if st:
strest.insert(0,st) st.extend(strest)
count = 0 count = 0
for item in strest: for item in st:
count = count + 1 count = count + 1
if self.test and count > 2: if self.test and count > 2:
return feeds return feeds
@ -151,7 +153,7 @@ class FinancialTimes(BasicNewsRecipe):
def get_cover_url(self): def get_cover_url(self):
cdate = datetime.date.today() cdate = datetime.date.today()
if cdate.isoweekday() == 7: if cdate.isoweekday() == 7:
cdate -= datetime.timedelta(days=1) cdate -= datetime.timedelta(days=1)
return cdate.strftime('http://specials.ft.com/vtf_pdf/%d%m%y_FRONT1_LON.pdf') return cdate.strftime('http://specials.ft.com/vtf_pdf/%d%m%y_FRONT1_LON.pdf')
def get_obfuscated_article(self, url): def get_obfuscated_article(self, url):
@ -163,9 +165,8 @@ class FinancialTimes(BasicNewsRecipe):
count = 10 count = 10
except: except:
print "Retrying download..." print "Retrying download..."
count += 1 count += 1
self.temp_files.append(PersistentTemporaryFile('_fa.html')) self.temp_files.append(PersistentTemporaryFile('_fa.html'))
self.temp_files[-1].write(html) self.temp_files[-1].write(html)
self.temp_files[-1].close() self.temp_files[-1].close()
return self.temp_files[-1].name return self.temp_files[-1].name