mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #7583 (Updated recipe for Al Jazeera in English)
This commit is contained in:
parent
573bd09555
commit
d2b427c3f9
@ -1,10 +1,8 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2009-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
|
||||||
'''
|
'''
|
||||||
aljazeera.net
|
english.aljazeera.net
|
||||||
'''
|
'''
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
@ -12,41 +10,59 @@ class AlJazeera(BasicNewsRecipe):
|
|||||||
title = 'Al Jazeera in English'
|
title = 'Al Jazeera in English'
|
||||||
__author__ = 'Darko Miletic'
|
__author__ = 'Darko Miletic'
|
||||||
description = 'News from Middle East'
|
description = 'News from Middle East'
|
||||||
language = 'en'
|
language = 'en'
|
||||||
|
|
||||||
publisher = 'Al Jazeera'
|
publisher = 'Al Jazeera'
|
||||||
category = 'news, politics, middle east'
|
category = 'news, politics, middle east'
|
||||||
simultaneous_downloads = 1
|
delay = 1
|
||||||
delay = 4
|
oldest_article = 2
|
||||||
oldest_article = 1
|
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
encoding = 'iso-8859-1'
|
encoding = 'iso-8859-1'
|
||||||
remove_javascript = True
|
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
|
extra_css = """
|
||||||
|
body{font-family: Arial,sans-serif}
|
||||||
|
#ctl00_cphBody_dvSummary{font-weight: bold}
|
||||||
|
#dvArticleDate{font-size: small; color: #999999}
|
||||||
|
"""
|
||||||
|
conversion_options = {
|
||||||
|
'comment' : description
|
||||||
|
, 'tags' : category
|
||||||
|
, 'publisher' : publisher
|
||||||
|
, 'language' : language
|
||||||
|
}
|
||||||
|
|
||||||
html2lrf_options = [
|
keep_only_tags = [
|
||||||
'--comment', description
|
dict(attrs={'id':['DetailedTitle','ctl00_cphBody_dvSummary','dvArticleDate']})
|
||||||
, '--category', category
|
,dict(name='td',attrs={'class':'DetailedSummary'})
|
||||||
, '--publisher', publisher
|
]
|
||||||
, '--ignore-tables'
|
|
||||||
]
|
|
||||||
|
|
||||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_table=True'
|
|
||||||
|
|
||||||
keep_only_tags = [dict(name='div', attrs={'id':'ctl00_divContent'})]
|
|
||||||
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name=['object','link'])
|
dict(name=['object','link','table','meta','base','iframe','embed'])
|
||||||
,dict(name='td', attrs={'class':['MostActiveDescHeader','MostActiveDescBody']})
|
,dict(name='td', attrs={'class':['MostActiveDescHeader','MostActiveDescBody']})
|
||||||
]
|
]
|
||||||
|
|
||||||
feeds = [(u'AL JAZEERA ENGLISH (AJE)', u'http://english.aljazeera.net/Services/Rss/?PostingId=2007731105943979989' )]
|
feeds = [(u'AL JAZEERA ENGLISH (AJE)', u'http://english.aljazeera.net/Services/Rss/?PostingId=2007731105943979989' )]
|
||||||
|
|
||||||
|
def get_article_url(self, article):
|
||||||
|
artlurl = article.get('link', None)
|
||||||
|
return artlurl.replace('http://english.aljazeera.net//','http://english.aljazeera.net/')
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for item in soup.findAll(style=True):
|
for item in soup.findAll(style=True):
|
||||||
del item['style']
|
del item['style']
|
||||||
for item in soup.findAll(face=True):
|
for item in soup.findAll(face=True):
|
||||||
del item['face']
|
del item['face']
|
||||||
|
td = soup.find('td',attrs={'class':'DetailedSummary'})
|
||||||
|
if td:
|
||||||
|
td.name = 'div'
|
||||||
|
spn = soup.find('span',attrs={'id':'DetailedTitle'})
|
||||||
|
if spn:
|
||||||
|
spn.name='h1'
|
||||||
|
for itm in soup.findAll('span', attrs={'id':['dvArticleDate','ctl00_cphBody_lblDate']}):
|
||||||
|
itm.name = 'div'
|
||||||
|
for alink in soup.findAll('a'):
|
||||||
|
if alink.string is not None:
|
||||||
|
tstr = alink.string
|
||||||
|
alink.replaceWith(tstr)
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user