mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-09-29 15:31:08 -04:00
81 lines
3.4 KiB
Plaintext
81 lines
3.4 KiB
Plaintext
|
|
__license__ = 'GPL v3'
|
|
__copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
|
|
'''
|
|
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'.*?<base', re.DOTALL|re.IGNORECASE),lambda match: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html dir="ltr" xml:lang="en-IN"><head><title>title</title><base')
|
|
,(re.compile(r'<base .*?>', re.DOTALL|re.IGNORECASE),lambda match: '</head><body>')
|
|
,(re.compile(r'<byline>', re.DOTALL|re.IGNORECASE),lambda match: '<div class="byline">')
|
|
,(re.compile(r'</byline>', re.DOTALL|re.IGNORECASE),lambda match: '</div>')
|
|
,(re.compile(r'<center>', re.DOTALL|re.IGNORECASE),lambda match: '<div class="ctr">')
|
|
,(re.compile(r'</center>', re.DOTALL|re.IGNORECASE),lambda match: '</div>')
|
|
]
|
|
|
|
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()
|