Update Countryfile

This commit is contained in:
Kovid Goyal 2013-09-02 08:54:03 +05:30
parent 55b40e7e65
commit 807213d5d0

View File

@ -20,27 +20,22 @@ class AdvancedUserRecipe1325006965(BasicNewsRecipe):
#article_already_exists = False #article_already_exists = False
#feed_hash = '' #feed_hash = ''
def get_cover_url(self): def get_cover_url(self):
soup = self.index_to_soup('http://www.countryfile.com/magazine') soup = self.index_to_soup('http://www.countryfile.com/magazine')
cov = soup.find(attrs={'class' : re.compile('imagecache imagecache-250px_wide')})#'width' : '160', cov = soup.find(attrs={'class' : re.compile('imagecache imagecache-250px')}) # 'width' : '160',
print '&&&&&&&& ',cov,' ***'
cov=str(cov)
#cov2 = re.findall('http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', cov)
cov2 = re.findall('/(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+', cov)
cov2 = str(cov2) cov=str(cov)
cov2= "http://www.countryfile.com"+cov2[2:len(cov2)-8] cov=cov[10:]
cov=cov[:-135]
print '******** ',cov2,' ***' br = browser()
# try to get cover - if can't get known cover br.set_handle_redirect(False)
br = browser() try:
br.open_novisit(cov)
br.set_handle_redirect(False) cover_url = cov
try: except:
br.open_novisit(cov2) cover_url = 'http://www.countryfile.com/sites/default/files/imagecache/160px_wide/cover/2_1.jpg'
cover_url = cov2 return cover_url
except: preprocess_regexps = [
cover_url = 'http://www.countryfile.com/sites/default/files/imagecache/160px_wide/cover/2_1.jpg' (re.compile(r' \| Countryfile.com', re.IGNORECASE | re.DOTALL), lambda match: '')]
return cover_url
remove_tags = [ remove_tags = [
# dict(attrs={'class' : ['player']}), # dict(attrs={'class' : ['player']}),
@ -48,6 +43,5 @@ class AdvancedUserRecipe1325006965(BasicNewsRecipe):
feeds = [ feeds = [
(u'Homepage', u'http://www.countryfile.com/rss/home'), (u'Homepage', u'http://www.countryfile.com/rss/home'),
(u'Country News', u'http://www.countryfile.com/rss/news'), (u'Country News', u'http://www.countryfile.com/rss/news'),
(u'Countryside', u'http://www.countryfile.com/rss/countryside'), (u'Countryside', u'http://www.countryfile.com/rss/countryside'),
] ]