__license__ = 'GPL v3' __copyright__ = '2011, Darko Miletic ' ''' frontlineonnet.com ''' import re from calibre.web.feeds.news import BasicNewsRecipe class Frontlineonnet(BasicNewsRecipe): title = 'Frontline' __author__ = 'Darko Miletic' description = "India's national magazine" publisher = 'Frontline' category = 'news, politics, India' no_stylesheets = True delay = 1 INDEX = 'http://frontlineonnet.com/' use_embedded_content = False encoding = 'utf-8' language = 'en_IN' publication_type = 'magazine' masthead_url = 'http://frontlineonnet.com/images/newfline.jpg' extra_css = """ body{font-family: Verdana,Arial,Helvetica,sans-serif} img{margin-top:0.5em; margin-bottom: 0.7em; display: block} """ conversion_options = { 'comment' : description , 'tags' : category , 'publisher' : publisher , 'language' : language , 'linearize_tables' : True } preprocess_regexps = [ (re.compile(r'.*?title', re.DOTALL|re.IGNORECASE),lambda match: '') ,(re.compile(r'', re.DOTALL|re.IGNORECASE),lambda match: '') ,(re.compile(r'
', re.DOTALL|re.IGNORECASE),lambda match: '
') ,(re.compile(r'
', re.DOTALL|re.IGNORECASE),lambda match: '') ] keep_only_tags= [ dict(name='div', attrs={'id':'content'}) #,dict(attrs={'class':'byline'}) ] #remove_attributes=['size','noshade','border'] #def preprocess_html(self, soup): #for item in soup.findAll(style=True): #del item['style'] #for item in soup.findAll('img'): #if not item.has_key('alt'): #item['alt'] = 'image' #return soup def parse_index(self): articles = [] soup = self.index_to_soup(self.INDEX) for feed_link in soup.findAll('div', id='headseccol'): a = feed_link.find('a', href=True) title = self.tag_to_string(a) url = a['href'] articles.append({ 'title' :title ,'date' :'' ,'url' :url ,'description':'' }) return [('Frontline', articles)] #def print_version(self, url): #return "http://www.hinduonnet.com/thehindu/thscrip/print.pl?prd=fline&file=" + url.rpartition('/')[2] #def image_url_processor(self, baseurl, url): #return url.replace('../images/', self.INDEX + 'images/').strip()