mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Merge branch 'master' of https://github.com/unkn0w7n/calibre
This commit is contained in:
commit
454b5f76e9
BIN
recipes/icons/ifzm.png
Normal file
BIN
recipes/icons/ifzm.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 726 B |
@ -1,56 +1,60 @@
|
|||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
import json
|
||||||
|
|
||||||
|
def json_to_html(raw, link):
|
||||||
|
data = json.loads(raw)
|
||||||
|
data = data['data']['content']
|
||||||
|
title = '<h1 title="{}">'.format(link) + data['subject'] + '</h1>'
|
||||||
|
auth = '<p><b>' + data['author'] + '</b></p>'
|
||||||
|
sub = '<p class="intro"><i>' + data['introtext'] + '</i></p>'
|
||||||
|
body = data['fulltext']
|
||||||
|
return '<html><body><div>' + title + auth + sub + body + '</div></body></html>'
|
||||||
|
|
||||||
|
|
||||||
class AdvancedUserRecipe1277305250(BasicNewsRecipe):
|
class infzm(BasicNewsRecipe):
|
||||||
title = u'infzm - China Southern Weekly'
|
title = '南方周末'
|
||||||
oldest_article = 14
|
__author__ = 'unkn0wn'
|
||||||
max_articles_per_feed = 100
|
description = 'Southern Weekly (infzm.com), founded in 1984, is a Chinese weekly newspaper based in Guangzhou. Download Weekly.'
|
||||||
|
|
||||||
feeds = [(u'\u5357\u65b9\u5468\u672b-\u70ed\u70b9\u65b0\u95fb', u'http://www.infzm.com/rss/home/rss2.0.xml'),
|
|
||||||
(u'\u5357\u65b9\u5468\u672b-\u7ecf\u6d4e\u65b0\u95fb',
|
|
||||||
u'http://www.infzm.com/rss/economic.xml'),
|
|
||||||
(u'\u5357\u65b9\u5468\u672b-\u6587\u5316\u65b0\u95fb',
|
|
||||||
u'http://www.infzm.com/rss/culture.xml'),
|
|
||||||
(u'\u5357\u65b9\u5468\u672b-\u751f\u6d3b\u65f6\u5c1a',
|
|
||||||
u'http://www.infzm.com/rss/lifestyle.xml'),
|
|
||||||
(u'\u5357\u65b9\u5468\u672b-\u89c2\u70b9',
|
|
||||||
u'http://www.infzm.com/rss/opinion.xml')
|
|
||||||
]
|
|
||||||
__author__ = 'rty'
|
|
||||||
__version__ = '1.0'
|
|
||||||
language = 'zh'
|
language = 'zh'
|
||||||
publisher = 'http://www.infzm.com'
|
encoding = 'utf-8'
|
||||||
description = 'Chinese Weekly Tabloid'
|
|
||||||
category = 'News, China'
|
|
||||||
remove_javascript = True
|
|
||||||
use_embedded_content = False
|
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
encoding = 'UTF-8'
|
remove_javascript = True
|
||||||
conversion_options = {'linearize_tables': True}
|
ignore_duplicate_articles = {'title'}
|
||||||
masthead_url = 'http://i50.tinypic.com/2qmfb7l.jpg'
|
remove_empty_feeds = True
|
||||||
|
use_embedded_content = False
|
||||||
|
remove_attributes = ['style', 'height', 'width']
|
||||||
|
masthead_url = 'http://ssimg.kkod.cn/web/02/14227.gif'
|
||||||
|
|
||||||
|
articles_are_obfuscated = True
|
||||||
|
|
||||||
|
remove_tags = [dict(name=['video', 'svg', 'button'])]
|
||||||
|
|
||||||
|
def get_obfuscated_article(self, url):
|
||||||
|
br = self.get_browser()
|
||||||
|
try:
|
||||||
|
br.open(url)
|
||||||
|
except Exception as e:
|
||||||
|
url = e.hdrs.get('location')
|
||||||
|
soup = self.index_to_soup(url)
|
||||||
|
link = soup.find('a', href=True)['href'].split('?')[0]
|
||||||
|
res_link = link.replace('https://www.infzm.com', 'https://api.infzm.com/mobile') \
|
||||||
|
+ '?platform=wap&version=1.89.0&machine_id=35458aa29603f2b246636e5492122b50&user_id=&token=&member_type='
|
||||||
|
# if article is paywalled, add code to figure out machine_id
|
||||||
|
raw = br.open(res_link).read()
|
||||||
|
html = json_to_html(raw, link)
|
||||||
|
return ({ 'data': html, 'url': link })
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
@font-face { font-family: "DroidFont", serif, sans-serif; src: url(res:///system/fonts/DroidSansFallback.ttf); }\n
|
img {display:block; margin:0 auto;}
|
||||||
body {
|
.cm_pic_caption, .cm_pic_author { font-size:small; text-align:center; }
|
||||||
margin-right: 8pt;
|
|
||||||
font-family: 'DroidFont', serif;}
|
|
||||||
.detailContent {font-family: 'DroidFont', serif, sans-serif}
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
keep_only_tags = [
|
feeds = [
|
||||||
dict(name='div', attrs={'id': 'detailContent'}),
|
('南方周末', 'https://news.google.com/rss/search?q=when:170h+allinurl:https%3A%2F%2Fwww.infzm.com&hl=zh-HK&gl=HK&ceid=HK:zh')
|
||||||
]
|
|
||||||
remove_tags = [
|
|
||||||
dict(name='div', attrs={
|
|
||||||
'id': ['detailTools', 'detailSideL', 'pageNum']}),
|
|
||||||
]
|
|
||||||
remove_tags_after = [
|
|
||||||
dict(name='div', attrs={'id': 'pageNum'}),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def populate_article_metadata(self, article, soup, first):
|
||||||
for item in soup.findAll(color=True):
|
article.title = article.title.replace(' - 南方周末', '')
|
||||||
del item['font']
|
article.url = soup.find('h1')['title']
|
||||||
for item in soup.findAll(style=True):
|
article.summary = self.tag_to_string(soup.find(attrs={'class':'intro'}))
|
||||||
del item['style']
|
article.text_summary = self.tag_to_string(soup.find(attrs={'class':'intro'}))
|
||||||
return soup
|
|
||||||
|
@ -5,12 +5,15 @@ class STHKRecipe(BasicNewsRecipe):
|
|||||||
__author__ = 'unkn0wn'
|
__author__ = 'unkn0wn'
|
||||||
description = 'The Sing Tao Daily is among Hong Kong\'s oldest Chinese language newspapers. (https://std.stheadline.com/)'
|
description = 'The Sing Tao Daily is among Hong Kong\'s oldest Chinese language newspapers. (https://std.stheadline.com/)'
|
||||||
category = 'Chinese, News, Hong Kong'
|
category = 'Chinese, News, Hong Kong'
|
||||||
|
language = 'zh'
|
||||||
|
encoding = 'utf-8'
|
||||||
masthead_url = 'https://std.stheadline.com/dist/images/logo-v2@2x.png'
|
masthead_url = 'https://std.stheadline.com/dist/images/logo-v2@2x.png'
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
ignore_duplicate_articles = {'title'}
|
ignore_duplicate_articles = {'title'}
|
||||||
resolve_internal_links = True
|
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
|
use_embedded_content = False
|
||||||
|
remove_attributes = ['style', 'height', 'width']
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
img {display:block; margin:0 auto;}
|
img {display:block; margin:0 auto;}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user