项目名是deepinbbs-rss的主要是针对Deepin深度新版论坛,特色是有摘要显示,这和其它的深度论坛RSS有所区别,网上很多是旧版的深度论坛RSS,及没有抓摘要,以下是deepinbbs-rss的成品截图:
deepinbbs-rss使用方法 先下载release里面的jar包,下载地址在https://github.com/zerofancy/deepinbbs-rss。 java -jar deepinbbs-rss-fat.jar --port 8080 到rss阅读器添加订阅: 全部:http://localhost:8080/all 热门:http://localhost:8080/hot 精华:http://localhost:8080/highlight 注:这里的--port参数是绑定的端口号,默认为8080。
附:更多参考 先装上pytz、PyRSS2Gen、Quart这三个工具,用pip3安装,参考在Debian 10/Debian 9发行版上安装Pip3和Pip2的方法。 然后把下面这些代码,存盘为deepin_rss.py,开终端跑起来。 最后rss阅读器连接http://127.0.0.1:60000即可。 代码如下: #!/bin/env python3 import pytz import datetime import PyRSS2Gen import requests from quart import Quart, abort app = Quart(__name__) tz = pytz.timezone('Asia/Shanghai') utc = pytz.utc def timeconvert(time): time = str(time).split('+')[0].split('T') date = time[0].split('-') time = time[1].split(':') time = datetime.datetime(int(date[0]), int(date[1]), int( date[2]), int(time[0]), int(time[1]), int(time[2])) return time.astimezone(utc) def buildtitle(item): title = '【' + item['type']['name'] + '】' + item['subject'] if item['top'] == 1: title = '【置顶】' + title return title def buildde*ion(item): return f"{item['forum']['name']} {item['user']['nickname']} · {item['updated_at_desc']} 最后回复{item['last_date_desc']} {item['views_cnt']}浏览 {item['posts_cnt']}评论" @app.route('/favicon.ico') async def favicon(): return "" @app.route('/') @app.route('/') @app.route('//') async def root(whare = '',limit = '100'): url = f'https://bbs.deepin.org/api/v1/thread/index?order=updated_at&limit={limit}&where={whare}&offset=0' headers = {'user-agent': 'daze/DRC/1.0.0'} deepin = requests.get(url=url, headers=headers) if deepin.status_code != 200: abort(deepin.status_code) else: deepin = deepin.json() deepin = deepin['ThreadIndex'] items = [] for item in deepin: url = 'https://bbs.deepin.org/post/' + str(item['id']) items.append(PyRSS2Gen.RSSItem(title=buildtitle(item), link=url, de*ion=buildde*ion(item), author=item['user']['nickname'], guid=PyRSS2Gen.Guid(url), pubDate=timeconvert(item['updated_at']))) for last in deepin: if last['top'] != 1: last = timeconvert(last['updated_at']) break rss = PyRSS2Gen.RSS2( title="深度论坛", link="https://bbs.deepin.org/index", de*ion="由DRC提供的适用于Deepin新版论坛的RSS订阅源", lastBuildDate=last, items=items, generator='DRC 1.0.0', docs="https://appstore.zdatek.top/daze/DRC") return rss.to_xml("utf-8"), 200, [('content-type', 'application/xml; charset=utf-8')] if __name__ == "__main__": print('DRC 1.0.0 Starting....') app.run(port=60000) 注:请记得先安装好pytz、PyRSS2Gen、Quart再使用以上代码。
相关主题 |