From bb7192911b4910cf138cb6d092ce18a0d8653e9b Mon Sep 17 00:00:00 2001 From: Luyu Huang Date: Tue, 17 Dec 2019 11:49:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20route=20for=20=E6=96=B0=E9=97=BB?= =?UTF-8?q?=E8=81=94=E6=92=AD=E6=96=87=E5=AD=97=E7=89=88=20(#3582)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/radar-rules.js | 12 ++++++++++++ docs/traditional-media.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/xinwenlianbo/index.js | 33 ++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 lib/routes/xinwenlianbo/index.js diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 9fd8c7fb74..953dd38daa 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -926,4 +926,16 @@ }, ], }, + + 'govopendata.com': { + _name: '新闻联播文字版', + cn: [ + { + title: '新闻联播文字版', + docs: 'https://docs.rsshub.app/traditional-media.html#xin-wen-lian-bo-wen-zi-ban', + source: '/xinwenlianbo', + target: '/xinwenlianbo/index', + }, + ], + }, }); diff --git a/docs/traditional-media.md b/docs/traditional-media.md index 33075862c4..1b6f995d5c 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -359,6 +359,12 @@ category 对应的关键词有 +## 新闻联播文字版 + +### 新闻联播文字版 + + + ## 央视新闻 ### 新闻联播 diff --git a/lib/router.js b/lib/router.js index abe4862274..73008b6351 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2035,4 +2035,7 @@ router.get('/mastodon/timeline/:site/:only_media?', require('./routes/mastodon/t // Kernel Aliyun router.get('/aliyun-kernel/index', require('./routes/aliyun-kernel/index')); +// xinwenlianbo +router.get('/xinwenlianbo/index', require('./routes/xinwenlianbo/index')); + module.exports = router; diff --git a/lib/routes/xinwenlianbo/index.js b/lib/routes/xinwenlianbo/index.js new file mode 100644 index 0000000000..7bd4060b18 --- /dev/null +++ b/lib/routes/xinwenlianbo/index.js @@ -0,0 +1,33 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +const root_url = 'https://cn.govopendata.com/xinwenlianbo/'; + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: root_url, + }); + + const $ = cheerio.load(response.data); + const list = $('table.table.table-bordered > tbody > tr > td') + .slice(0, 10) + .map((_, item) => { + item = $(item); + const a = item.find('a'); + const title = a.text(); + return { + title: title, + link: a.attr('href'), + description: item.find('ul').html(), + pubDate: new Date(/(\d{4}-\d+-\d+)/.exec(title)[1] + ' 19:00 GMT+8').toUTCString(), + }; + }) + .get(); + + ctx.state.data = { + title: '新闻联播 文字版', + link: root_url, + item: list, + }; +};