From 2c20ad3092c4f4079f7eb53c7acdd091fc2032ca Mon Sep 17 00:00:00 2001 From: cnkmmk <22782790+cnkmmk@users.noreply.github.com> Date: Sat, 17 Feb 2024 23:36:08 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E7=94=B5=E8=84=91?= =?UTF-8?q?=E7=8E=A9=E7=89=A9=20(#14486)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加电脑玩物 * style: auto format * Update radar.js --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/v2/playpcesor/maintainer.js | 3 +++ lib/v2/playpcesor/radar.js | 13 +++++++++++++ lib/v2/playpcesor/router.js | 3 +++ lib/v2/playpcesor/rss.js | 32 ++++++++++++++++++++++++++++++++ website/docs/routes/blog.mdx | 6 ++++++ 5 files changed, 57 insertions(+) create mode 100644 lib/v2/playpcesor/maintainer.js create mode 100644 lib/v2/playpcesor/radar.js create mode 100644 lib/v2/playpcesor/router.js create mode 100644 lib/v2/playpcesor/rss.js diff --git a/lib/v2/playpcesor/maintainer.js b/lib/v2/playpcesor/maintainer.js new file mode 100644 index 000000000..387d961bf --- /dev/null +++ b/lib/v2/playpcesor/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['cnkmmk'], +}; diff --git a/lib/v2/playpcesor/radar.js b/lib/v2/playpcesor/radar.js new file mode 100644 index 000000000..804427e50 --- /dev/null +++ b/lib/v2/playpcesor/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'playpcesor.com': { + _name: '电脑玩物', + '.': [ + { + title: '博客', + docs: 'https://docs.rsshub.app/routes/blog#dian-nao-wan-wu', + source: ['/'], + target: '/playpcesor', + }, + ], + }, +}; diff --git a/lib/v2/playpcesor/router.js b/lib/v2/playpcesor/router.js new file mode 100644 index 000000000..574929e02 --- /dev/null +++ b/lib/v2/playpcesor/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./rss')); +}; diff --git a/lib/v2/playpcesor/rss.js b/lib/v2/playpcesor/rss.js new file mode 100644 index 000000000..6e37e0e42 --- /dev/null +++ b/lib/v2/playpcesor/rss.js @@ -0,0 +1,32 @@ +const { parseDate } = require('@/utils/parse-date'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const url = 'https://www.playpcesor.com/'; + const response = await got({ method: 'get', url }); + const $ = cheerio.load(response.data); + + const list = $("article[class='post-outer-container']") + .map((i, e) => { + const element = $(e); + const title = element.find('h3 > a').text(); + const link = element.find('h3 > a').attr('href'); + const description = element.find('div[class="snippet-item r-snippetized"]').text(); + const dateraw = element.find('time').attr('datetime'); + + return { + title, + description, + link, + pubDate: parseDate(dateraw, 'YYYY-MM-DDTHH:mm:ss+08:00'), + }; + }) + .get(); + + ctx.state.data = { + title: '电脑玩物', + link: url, + item: list, + }; +}; diff --git a/website/docs/routes/blog.mdx b/website/docs/routes/blog.mdx index 78cdebcc5..a0508e8f8 100644 --- a/website/docs/routes/blog.mdx +++ b/website/docs/routes/blog.mdx @@ -312,6 +312,12 @@ | windows | android | tutorial | other | +## 电脑玩物 {#dian-nao-wan-wu} + +### 博客 {#dian-nao-wan-wu-bo-ke} + + + ## 纷享销客 CRM {#fen-xiang-xiao-ke-crm} ### 文章 {#fen-xiang-xiao-ke-crm-wen-zhang}