From f02487a97c10e38ccb6755f5c857f71c199272eb Mon Sep 17 00:00:00 2001 From: cnkmmk <22782790+cnkmmk@users.noreply.github.com> Date: Thu, 29 Feb 2024 00:08:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E8=B5=B5=E5=AE=B9?= =?UTF-8?q?=E9=83=A8=E8=90=BD=20(#14580)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/v2/zrblog/maintainer.js | 3 +++ lib/v2/zrblog/radar.js | 13 +++++++++++++ lib/v2/zrblog/router.js | 3 +++ lib/v2/zrblog/rss.js | 34 ++++++++++++++++++++++++++++++++++ website/docs/routes/blog.mdx | 6 ++++++ 5 files changed, 59 insertions(+) create mode 100644 lib/v2/zrblog/maintainer.js create mode 100644 lib/v2/zrblog/radar.js create mode 100644 lib/v2/zrblog/router.js create mode 100644 lib/v2/zrblog/rss.js diff --git a/lib/v2/zrblog/maintainer.js b/lib/v2/zrblog/maintainer.js new file mode 100644 index 000000000..387d961bf --- /dev/null +++ b/lib/v2/zrblog/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['cnkmmk'], +}; diff --git a/lib/v2/zrblog/radar.js b/lib/v2/zrblog/radar.js new file mode 100644 index 000000000..8cca4f907 --- /dev/null +++ b/lib/v2/zrblog/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'zrblog.net': { + _name: '赵容部落', + '.': [ + { + title: '博客', + docs: 'https://docs.rsshub.app/routes/blog#zhao-rong-bu-luo', + source: ['/'], + target: '/zrblog', + }, + ], + }, +}; diff --git a/lib/v2/zrblog/router.js b/lib/v2/zrblog/router.js new file mode 100644 index 000000000..574929e02 --- /dev/null +++ b/lib/v2/zrblog/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./rss')); +}; diff --git a/lib/v2/zrblog/rss.js b/lib/v2/zrblog/rss.js new file mode 100644 index 000000000..ce5ebcd31 --- /dev/null +++ b/lib/v2/zrblog/rss.js @@ -0,0 +1,34 @@ +const { parseDate } = require('@/utils/parse-date'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + + +module.exports = async (ctx) => { + const url = 'https://www.zrblog.net/'; + const response = await got({ method: 'get', url }); + const $ = cheerio.load(response.data); + + const list = $("div.art_img_box") + .map((i, e) => { + const element = $(e); + const title = element.find('h2 > a').attr('title'); + const link = element.find('h2 > a').attr('href'); + const description = element.find('p.intro').text(); + const dateraw = element.find("div.info").find('span').eq(0).text(); + + return { + title, + description, + link, + pubDate: parseDate(dateraw, '发布日期:YYYY年MM月DD日'), + }; + }) + .get(); + + + ctx.state.data = { + title: '赵容部落', + link: url, + item: list, + }; +}; \ No newline at end of file diff --git a/website/docs/routes/blog.mdx b/website/docs/routes/blog.mdx index 157ffada8..82c6608bd 100644 --- a/website/docs/routes/blog.mdx +++ b/website/docs/routes/blog.mdx @@ -485,3 +485,9 @@ ### 上周热门 TOP 20 {#zhu-bai-shang-zhou-re-men-top-20} + +## 赵容部落 {#zhao-rong-bu-luo} + +### 博客 {#zhao-rong-bu-luo-bo-ke} + + \ No newline at end of file