From d560842370d184948867a99e72a0c0fd363a79ec Mon Sep 17 00:00:00 2001 From: hillerliao Date: Wed, 5 Feb 2020 12:44:53 +0800 Subject: [PATCH] fetch dxzg notice --- .gitignore | 4 +++- rsshub/blueprints/main.py | 5 +++++ rsshub/spiders/dxzg/notice.py | 24 ++++++++++++++++++++++++ rsshub/templates/main/feeds.html | 11 +++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 rsshub/spiders/dxzg/notice.py diff --git a/.gitignore b/.gitignore index 38946f4..66d60ec 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,6 @@ venv .vscode .coverage htmlcov/ -data-dev.db \ No newline at end of file +data-dev.db + +.env \ No newline at end of file diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index ff42241..cfef6a0 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -57,3 +57,8 @@ def ctolib_topics(category=''): def infoq_recommend(): from rsshub.spiders.infoq.recommend import ctx return render_template('main/atom.xml', **filter_content(ctx())) + +@bp.route('/dxzg/notice') +def dxzg_notice(): + from rsshub.spiders.dxzg.notice import ctx + return render_template('main/atom.xml', **filter_content(ctx())) diff --git a/rsshub/spiders/dxzg/notice.py b/rsshub/spiders/dxzg/notice.py new file mode 100644 index 0000000..359b6a5 --- /dev/null +++ b/rsshub/spiders/dxzg/notice.py @@ -0,0 +1,24 @@ +from rsshub.utils import fetch + +domain = 'http://www.dxzq.net' + + +def parse(post): + item = {} + item['description'] = item['title'] = post.css('a::text').extract_first() + link = f"{domain}{post.css('a::attr(href)').extract_first()}" + item['link'] = link + item['pubDate'] = post.css('span.time::text').extract_first() + return item + + +def ctx(category=''): + tree = fetch(f"{domain}/main/zcgl/zxgg/index.shtml?catalogId=1,5,228") + posts = tree.css('.news_list li') + return { + 'title': '东兴资管产品最新公告', + 'link': domain, + 'description': '东兴资管产品最新公告', + 'author': 'hillerliao', + 'items': list(map(parse, posts)) + } \ No newline at end of file diff --git a/rsshub/templates/main/feeds.html b/rsshub/templates/main/feeds.html index 39336e5..7010d15 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -74,4 +74,15 @@
+ +
+
+

东兴资管

+
产品公告 by hillerliao
+

举例:https://rsshub-python.herokuapp.com/dxzg/notice

+

路由:/dxzg/notice

+
+
+
+ {% endblock content %} \ No newline at end of file