diff --git a/Pipfile b/Pipfile index aacd0f6..bba1c60 100644 --- a/Pipfile +++ b/Pipfile @@ -5,6 +5,7 @@ name = "pypi" [packages] bootstrap-flask = "*" +feedparser = "*" flask-debugtoolbar = "*" flask-moment = "*" Flask = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 3a46458..9cbded3 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "2bf1ccf68553a24a83089a5c5f7e67c109abb959f66568559f8a1593fd878fd5" + "sha256": "244fdb2ca7e1595ca468c0f56bb8936b1fa6efce78ace99461e8ca813fe7114f" }, "pipfile-spec": 6, "requires": {}, @@ -81,6 +81,14 @@ ], "version": "==0.8.3" }, + "feedparser": { + "hashes": [ + "sha256:1b7f57841d9cf85074deb316ed2c795091a238adb79846bc46dccdaf80f9c59a", + "sha256:5ce0410a05ab248c8c7cfca3a0ea2203968ee9ff4486067379af4827a59f9661" + ], + "index": "pypi", + "version": "==6.0.8" + }, "flask": { "hashes": [ "sha256:315ded2ddf8a6281567edb27393010fe3406188bafbfe65a3339d5787d89e477", @@ -225,6 +233,12 @@ "markers": "python_version >= '3.7'", "version": "==62.2.0" }, + "sgmllib3k": { + "hashes": [ + "sha256:7868fb1c8bfa764c1ac563d3cf369c381d1325d36124933a726f29fcdaa812e9" + ], + "version": "==1.0.0" + }, "six": { "hashes": [ "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", @@ -291,11 +305,11 @@ }, "coverage": { "hashes": [ - "sha256:03e2a7826086b91ef345ff18742ee9fc47a6839ccd517061ef8fa1976e652ce9", - "sha256:b78e5afb39941572209f71866aa0b206c12f0109835aa0d601e41552f9b3e620" + "sha256:2781c43bffbbec2b8867376d4d61916f5e9c4cc168232528562a61d1b4b01879", + "sha256:cc692c9ee18f0dd3214843779ba6b275ee4bb9b9a5745ba64265bce911aefd1a" ], "index": "pypi", - "version": "==6.3.2" + "version": "==6.3.3" }, "dill": { "hashes": [ @@ -422,11 +436,11 @@ }, "pylint": { "hashes": [ - "sha256:ced8968c3b699df0615e2a709554dec3ddac2f5cd06efadb69554a69eeca364a", - "sha256:f87e863a0b08f64b5230e7e779bcb75276346995737b2c0dc2793070487b1ff6" + "sha256:095567c96e19e6f57b5b907e67d265ff535e588fe26b12b5ebe1fc5645b2c731", + "sha256:705c620d388035bdd9ff8b44c5bcdd235bfb49d276d488dd2c8ff1736aa42526" ], "index": "pypi", - "version": "==2.13.8" + "version": "==2.13.9" }, "setuptools": { "hashes": [ diff --git a/rsshub/blueprints/main.py b/rsshub/blueprints/main.py index 630dbed..2424080 100644 --- a/rsshub/blueprints/main.py +++ b/rsshub/blueprints/main.py @@ -220,6 +220,12 @@ def bjnews_channel(category=''): from rsshub.spiders.bjnews.channel import ctx return render_template('main/atom.xml', **filter_content(ctx(category))) +@bp.route('/filter/') +def rss_filter(): + from rsshub.spiders.rssfilter.filter import ctx + feed_url = request.args.get("feed") + return render_template('main/atom.xml', **filter_content(ctx(feed_url))) + ''' @bp.route('/test') @bp.route('/test/测试') diff --git a/rsshub/spiders/rssfilter/filter.py b/rsshub/spiders/rssfilter/filter.py new file mode 100644 index 0000000..fa70b00 --- /dev/null +++ b/rsshub/spiders/rssfilter/filter.py @@ -0,0 +1,34 @@ +import requests +import feedparser + +from rsshub.utils import DEFAULT_HEADERS +from rsshub.utils import fetch + +def parse(post): + item = {} + item['title'] = post.title + item['description'] = post.summary + item['pubDate'] = post.published + item['link'] = post.link + return item + +def ctx(feed_url=''): + # tree = fetch(feed_url,headers=DEFAULT_HEADERS) + # title = tree.css('channel').css('title::text').get() + # description = tree.css('channel').css('description').get() + # posts = tree.css('item') + + feed = feedparser.parse(feed_url) + + title = feed.feed.title + description = feed.feed.subtitle + + posts = feed.entries + + return { + 'title': title, + 'link': feed_url, + 'description': description, + 'author': feed.feed.author, + '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 e51f920..b460af5 100644 --- a/rsshub/templates/main/feeds.html +++ b/rsshub/templates/main/feeds.html @@ -1,9 +1,40 @@ {% extends "layout.html" %} {% block title %}All Feeds{% endblock title %} {% block content %} + + +
+
+

RSS Filter参数

+
RSS 过滤参数by hillerliao
+

举例:https://pyrsshub.vercel.app/filter?feed=https://sspai.com/feed&include_title=派早报

+

参数:include_title 匹配标题

+

参数:include_description 匹配摘要

+

参数:exclude_title 排除标题

+

参数:exclude_description 排除摘要

+

参数:limit 限制条数

+ +
+
+
+ + + +
+
+

RSS 代理

+
RSS 代理 by hillerliao
+

举例:https://pyrsshub.vercel.app/filter?feed=https://sspai.com/feed

+

路由:/filter?feed=:feed

+

参数:feed [rss 地址]

+
+
+
+ +

传送门-失效

文章 by alphardex
-

举例:https://rsshub.deta.dev/chuansongme/articles

+

举例:https://pyrsshub.vercel.app/chuansongme/articles

路由:/chuansongme/articles/:category

参数:category [默认为“最新”]

@@ -25,11 +56,12 @@
+

CTOLib-失效

话题 by alphardex
-

举例:https://rsshub.deta.dev/ctolib/topics

+

举例:https://pyrsshub.vercel.app/ctolib/topics

路由:/ctolib/topics/:category

参数:category [默认为“默认排序”]

@@ -55,11 +87,11 @@

InfoQ

推荐内容 by alphardex hillerliao
-

举例:https://rsshub.deta.dev/infoq/recommend

+

举例:https://pyrsshub.vercel.app/infoq/recommend

路由:/infoq/recommend

主题内容 by hillerliao
-

举例:https://rsshub.deta.dev/infoq/topic/159

+

举例:https://pyrsshub.vercel.app/infoq/topic/159

路由:/infoq/topic/:category

@@ -68,8 +100,8 @@

巨潮资讯

公司公告 by hillerliao
-

举例:https://rsshub.deta.dev/cninfo/announcement/all/gqjl

-

举例:https://rsshub.deta.dev/cninfo/announcement/all/gqbd_预披露,股权变动类公告中标题含有「预披露」的公告

+

举例:https://pyrsshub.vercel.app/cninfo/announcement/all/gqjl

+

举例:https://pyrsshub.vercel.app/cninfo/announcement/all/gqbd_预披露,股权变动类公告中标题含有「预披露」的公告

路由:/cninfo/announcement/:stock_id/:category

@@ -79,7 +111,7 @@

东兴资管

产品公告 by hillerliao
-

举例:https://rsshub.deta.dev/dxzg/notice

+

举例:https://pyrsshub.vercel.app/dxzg/notice

路由:/dxzg/notice

@@ -91,7 +123,7 @@

Earnings Date

Earnings Date by hillerliao
-

举例:https://rsshub.deta.dev/earningsdate/businesswire

+

举例:https://pyrsshub.vercel.app/earningsdate/businesswire

路由:/earningsdate/:category

参数:category [必填,可以为“businesswire、globenewswire、prnewswire”]

@@ -104,7 +136,7 @@

界面快讯

界面快讯 by hillerliao
-

举例:https://rsshub.deta.dev/jiemian/newsflash/166

+

举例:https://pyrsshub.vercel.app/jiemian/newsflash/166

路由:/jiemian/newsflash/:category

参数:category [必填,见界面快讯栏目https://www.jiemian.com/lists/4.html]

@@ -117,7 +149,7 @@

证监会审核进度

证监会审核进度 by hillerliao
-

举例:https://rsshub.deta.dev/csrc/audit/a1d50077cd7f4b15bd1c8d6163f32850

+

举例:https://pyrsshub.vercel.app/csrc/audit/a1d50077cd7f4b15bd1c8d6163f32850

路由:/csrc/audit/:category

参数:category [必填,见证监会栏目 https://neris.csrc.gov.cn/alappl/home/gongshi]

@@ -130,7 +162,7 @@

财新网滚动新闻

财新网滚动新闻 by hillerliao
-

举例:https://rsshub.deta.dev/caixin/scroll/125

+

举例:https://pyrsshub.vercel.app/caixin/scroll/125

路由:/caixin/scroll/:category

参数:category [必填,见财新网滚动频道 http://www.caixin.com/search/scroll/0.jsp]

@@ -143,7 +175,7 @@

东方财富网行业/个股研报

东方财富网行业/个股研报 by hillerliao
-

举例:https://rsshub.deta.dev/eastmoney/report/stock/473

+

举例:https://pyrsshub.vercel.app/eastmoney/report/stock/473

路由:/eastmoney/report/:type/:category

参数:type, category [必填,见东方财富网研报频道 ]

@@ -156,7 +188,7 @@

选股宝板块/主题动态

选股宝板块/主题动态 by hillerliao
-

举例:https://rsshub.deta.dev/xuangubao/theme/17006066

+

举例:https://pyrsshub.vercel.app/xuangubao/theme/17006066

路由:/xuangubao/:type/:category

参数:type = theme|subject, category [必填,板块/主题ID]

@@ -169,7 +201,7 @@

财联社主题动态

财联社主题动态 by hillerliao
-

举例:https://rsshub.deta.dev/cls/subject/1345

+

举例:https://pyrsshub.vercel.app/cls/subject/1345

路由:/cls/subject/:category

参数:category [必填,见财联社APP主题栏目]

@@ -182,7 +214,7 @@

财联社电报

财联社电报 by hillerliao
-

举例:https://rsshub.deta.dev/cls/telegraph

+

举例:https://pyrsshub.vercel.app/cls/telegraph

路由:/cls/telegraph

@@ -194,7 +226,7 @@

链得得栏目动态

链得得栏目动态 by hillerliao
-

举例:https://rsshub.deta.dev/chaindd/column/3158465

+

举例:https://pyrsshub.vercel.app/chaindd/column/3158465

路由:/chaindd/column/:category

参数:category [必填,见链得得栏目url中的数字编号]

@@ -207,7 +239,7 @@

早报网 即时新闻文章列表

早报网 即时新闻文章列表 by hillerliao
-

举例:https://rsshub.deta.dev/zaobao/realtime/china

+

举例:https://pyrsshub.vercel.app/zaobao/realtime/china

路由:/zaobao/realtime/:category

参数:category [必填,见 早报网 官网]

@@ -220,7 +252,7 @@

Techcrunch tag文章列表

Techcrunch tag文章列表 by hillerliao
-

举例:https://rsshub.deta.dev/techcrunch/tag/216504

+

举例:https://pyrsshub.vercel.app/techcrunch/tag/216504

路由:/techcrunch/tag/:category

参数:category [必填,见 techcrunch 官网]

@@ -233,7 +265,7 @@

未央网-首页

未央网-首页 by hillerliao
-

举例:https://rsshub.deta.dev/weiyangx/home/

+

举例:https://pyrsshub.vercel.app/weiyangx/home/

路由:/weiyangx/home/

@@ -245,7 +277,7 @@

未央网-国际快讯

未央网-国际快讯 by hillerliao
-

举例:https://rsshub.deta.dev/weiyangx/express/

+

举例:https://pyrsshub.vercel.app/weiyangx/express/

路由:/weiyangx/express/

@@ -257,7 +289,7 @@

扬帆出海-快讯

扬帆出海-快讯 by hillerliao
-

举例:https://rsshub.deta.dev/yfchuhai/express/

+

举例:https://pyrsshub.vercel.app/yfchuhai/express/

路由:/yfchuhai/express/

@@ -269,7 +301,7 @@

未央网 tag文章列表

未央网 tag文章列表 by hillerliao
-

举例:https://rsshub.deta.dev/weiyangx/tag/金融科技

+

举例:https://pyrsshub.vercel.app/weiyangx/tag/金融科技

路由:/weiyangx/tag/:category

参数:category [必填,见 weiyangx 官网]

@@ -282,7 +314,7 @@

今天看啥专栏文章列表

今天看啥专栏文章列表 by hillerliao
-

举例:https://rsshub.deta.dev/jintiankansha/column/KgkNwnDrsy

+

举例:https://pyrsshub.vercel.app/jintiankansha/column/KgkNwnDrsy

路由:/jintiankansha/column/:category

参数:category [必填,见 jintiankansha.me]

@@ -295,7 +327,7 @@

产品公告 - 机构间市场

产品公告 - 机构间市场 by hillerliao
-

举例:https://rsshub.deta.dev/interotc/cpgg/东兴证券

+

举例:https://pyrsshub.vercel.app/interotc/cpgg/东兴证券

路由:/interotc/cpgg/:category

参数:category [必填,标题中的关键词]

@@ -308,7 +340,7 @@

股票评级 - Benzinga

股票评级 - Benzinga by hillerliao
-

举例:https://rsshub.deta.dev/benzinga/ratings/wb

+

举例:https://pyrsshub.vercel.app/benzinga/ratings/wb

路由:/benzinga/ratings/:category

参数:category [必填, 股票代码]

@@ -321,7 +353,7 @@

抽屉新热榜 - 用户

抽屉新热榜 - 用户 by hillerliao
-

举例:https://rsshub.deta.dev/chouti/user/wb_5517143496

+

举例:https://pyrsshub.vercel.app/chouti/user/wb_5517143496

路由:/chouti/user/:category

参数:category [必填, 用户id]

@@ -334,7 +366,7 @@

抽屉新热榜 - 话题

抽屉新热榜 - 话题 by hillerliao
-

举例:https://rsshub.deta.dev/chouti/section/1116

+

举例:https://pyrsshub.vercel.app/chouti/section/1116

路由:/chouti/section/:category

参数:category [必填, 话题id]

@@ -347,7 +379,7 @@

抽屉新热榜 - 搜索

抽屉新热榜 - 搜索 by hillerliao
-

举例:https://rsshub.deta.dev/chouti/search/China

+

举例:https://pyrsshub.vercel.app/chouti/search/China

路由:/chouti/search/:category

参数:category [必填, 搜索关键词]

@@ -360,7 +392,7 @@

微信公众号 - 标签文章列表

微信公众号 - 标签文章列表 by hillerliao
-

举例:https://rsshub.deta.dev/mp/tag/MzI5MjM3OTA0MA/1500461858015772673

+

举例:https://pyrsshub.vercel.app/mp/tag/MzI5MjM3OTA0MA/1500461858015772673

路由:/mp/tag/:biz/:tag

biz [必填, 公众号id],tag,[必填, 标签 id]

@@ -373,7 +405,7 @@

Producthunt - 搜索结果

Producthunt - 搜索结果 by hillerliao
-

举例:https://rsshub.deta.dev/producthunt/search/wechat/30

+

举例:https://pyrsshub.vercel.app/producthunt/search/wechat/30

路由:/producthunt/search/:keyword/:period

keyword [必填, 搜索关键词],period,[必填, 时间范围]

@@ -386,7 +418,7 @@

蒲公英 - App 更新日志

蒲公英 - App 更新日志by hillerliao
-

举例:https://rsshub.deta.dev/pgyer/22bY

+

举例:https://pyrsshub.vercel.app/pgyer/22bY

路由:/pgyer/:pageid

pageid [必填, 页面 id]

@@ -399,7 +431,7 @@

新京报 - 频道

新京报 - 频道by hillerliao
-

举例:https://rsshub.deta.dev/bjnews/beijing

+

举例:https://pyrsshub.vercel.app/bjnews/beijing

路由:/bjnews/:channelid

channelid [必填, 频道 id]

@@ -412,7 +444,7 @@

微信公众号 - 最新文章 - 搜狗方案

微信公众号 - 最新文章 by hillerliao
-

举例:https://rsshub.deta.dev/mp/gh/mao-talk

+

举例:https://pyrsshub.vercel.app/mp/gh/mao-talk

路由:/mp/tag/:biz/:tag

gh [必填, 公众号id]

@@ -425,7 +457,7 @@

微信公众号 - 最新文章 - 游无穷

微信公众号 - 最新文章 by hillerliao
-

举例:https://rsshub.deta.dev/mp/youwuqiong/maoyouhuashuo

+

举例:https://pyrsshub.vercel.app/mp/youwuqiong/maoyouhuashuo

路由:/mp/youwuqiong/:author

author [必填, 作者id,在 youwuqiong.com 文章列表页上找]