From b1a2a8b83981e460fd0d931e4b5fc4455ae76d07 Mon Sep 17 00:00:00 2001 From: hillerliao Date: Tue, 14 Apr 2020 08:05:31 +0800 Subject: [PATCH] add jintiankansha --- rsshub/blueprints/main.py | 7 ++++++- rsshub/spiders/jintiankansha/column.py | 27 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 rsshub/spiders/jintiankansha/column.py diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 3c152bc..a667c67 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -134,4 +134,9 @@ def weiyangx_express(): @bp.route('/weiyangx/tag/') def weiyangx_tag(category=''): from rsshub.spiders.weiyangx.tag import ctx - return render_template('main/atom.xml', **filter_content(ctx(category))) \ No newline at end of file + return render_template('main/atom.xml', **filter_content(ctx(category))) + +@bp.route('/jintiankansha/column/') +def jintiankansha_column(category=''): + from rsshub.spiders.jintiankansha.column import ctx + return render_template('main/atom.xml', **filter_content(ctx(category))) \ No newline at end of file diff --git a/rsshub/spiders/jintiankansha/column.py b/rsshub/spiders/jintiankansha/column.py new file mode 100644 index 0000000..20adfe7 --- /dev/null +++ b/rsshub/spiders/jintiankansha/column.py @@ -0,0 +1,27 @@ +from rsshub.utils import DEFAULT_HEADERS +from rsshub.utils import fetch + +domain = 'http://www.jintiankansha.me' + + +def parse(post): + item = {} + item['description'] = item['title'] = post.css('a::text').extract_first() + item['link'] = post.css('a::attr(href)').extract_first() + return item + + +def ctx(category=''): + url = f'{domain}/column/{category}' + tree = fetch(url, headers=DEFAULT_HEADERS) + posts = tree.css('.cell.item') + items = list(map(parse, posts)) + + column_title = tree.css('title::text').extract_first() + return { + 'title': f'{column_title}', + 'description': f'{category}', + 'link': url, + 'author': f'hillerliao', + 'items': items + }