From fc91df64d7fafca96bbb324b785cc81d8ed2bea2 Mon Sep 17 00:00:00 2001 From: kaiili <35690781+kaiili@users.noreply.github.com> Date: Sat, 27 Nov 2021 15:56:36 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E5=AE=89=E5=85=A8=E6=96=87=E6=91=98=20(#?= =?UTF-8?q?8294)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: testkaili Co-authored-by: kaiili --- docs/programming.md | 6 ++++++ lib/v2/secnews/index.js | 27 +++++++++++++++++++++++++++ lib/v2/secnews/maintainer.js | 3 +++ lib/v2/secnews/radar.js | 13 +++++++++++++ lib/v2/secnews/router.js | 3 +++ 5 files changed, 52 insertions(+) create mode 100644 lib/v2/secnews/index.js create mode 100644 lib/v2/secnews/maintainer.js create mode 100644 lib/v2/secnews/radar.js create mode 100644 lib/v2/secnews/router.js diff --git a/docs/programming.md b/docs/programming.md index 320340c46..4370bb4c7 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -450,6 +450,12 @@ GitHub 官方也提供了一些 RSS: +## 安全文摘 + +### 首页 + + + ## 饿了么开放平台 ### 商家开放平台公告 diff --git a/lib/v2/secnews/index.js b/lib/v2/secnews/index.js new file mode 100644 index 000000000..c131aa35a --- /dev/null +++ b/lib/v2/secnews/index.js @@ -0,0 +1,27 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'http://wiki.ioin.in/'; + const response = await got.get(String(url)); + const $ = cheerio.load(response.data); + const list = $('table>tbody>tr').get(); + const items = list.map((i) => { + const item = $(i); + const title = item.find('td:nth-child(2) a').text(); + const pla = item.find('.vul-type-item').text().replace(/\s+/g, ''); + const date = new Date(item.find('td:first-child').text().replace(/\s+/g, '')).toUTCString(); + const href = item.find('td:nth-child(2) a').attr('href'); + return { + title: `${title} ${pla !== '未知' ? pla : ''}`, + pubDate: date, + link: `${url}${href}`, + }; + }); + + ctx.state.data = { + title: 'sec-news', + link: 'http://wiki.ioin.in/', + item: items, + }; +}; diff --git a/lib/v2/secnews/maintainer.js b/lib/v2/secnews/maintainer.js new file mode 100644 index 000000000..8fd867f26 --- /dev/null +++ b/lib/v2/secnews/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/index': ['kaiili'], +}; diff --git a/lib/v2/secnews/radar.js b/lib/v2/secnews/radar.js new file mode 100644 index 000000000..327078daa --- /dev/null +++ b/lib/v2/secnews/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'furstar.jp': { + _name: 'Furstar', + '.': [ + { + title: '安全文摘首頁', + docs: 'https://docs.rsshub.app/shopping.html#an-quan-wen-zhai', + source: ['/', '/'], + target: '/secnews/index', + }, + ], + }, +}; diff --git a/lib/v2/secnews/router.js b/lib/v2/secnews/router.js new file mode 100644 index 000000000..437937a54 --- /dev/null +++ b/lib/v2/secnews/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('', require('./index')); +};