From 1caaa4f57839d10150749672ce3815279cedd5b1 Mon Sep 17 00:00:00 2001 From: cnkmmk <22782790+cnkmmk@users.noreply.github.com> Date: Thu, 22 Feb 2024 23:21:06 +0800 Subject: [PATCH] feat(route): add HiFeng'Blog (#14518) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 增加 免費資源網路社群 * style: auto format * 更新 rss.js 使用 wordpress 的 api 来获取数据 * 更新 rss.js * 更新 rss.js * 更新 rss.js * 增加 HiFeng'Blog * 更新 rss.js * 更新 rss.js * 更新 rss.js * 更新 rss.js * 更新 rss.js * 更新 rss.js * 更新 rss.js * 更新 rss.js * 更新 rss.js * 1 * 2 * 3 * 4 * 更新 rss.js * 1 * 更新 router.js * 更新 rss1.js * 改router文件 * 更新 rss.js * 修改 hicairo * 更新 radar.js * 更新 rss.js * 更新 rss.js * Update lib/v2/hicairo/radar.js Co-authored-by: Tony --------- Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- lib/v2/hicairo/maintainer.js | 3 +++ lib/v2/hicairo/radar.js | 13 +++++++++++++ lib/v2/hicairo/router.js | 3 +++ lib/v2/hicairo/rss.js | 32 ++++++++++++++++++++++++++++++++ website/docs/routes/blog.mdx | 6 ++++++ 5 files changed, 57 insertions(+) create mode 100644 lib/v2/hicairo/maintainer.js create mode 100644 lib/v2/hicairo/radar.js create mode 100644 lib/v2/hicairo/router.js create mode 100644 lib/v2/hicairo/rss.js diff --git a/lib/v2/hicairo/maintainer.js b/lib/v2/hicairo/maintainer.js new file mode 100644 index 0000000000..387d961bfe --- /dev/null +++ b/lib/v2/hicairo/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/': ['cnkmmk'], +}; diff --git a/lib/v2/hicairo/radar.js b/lib/v2/hicairo/radar.js new file mode 100644 index 0000000000..19ea0e6c4c --- /dev/null +++ b/lib/v2/hicairo/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'hicairo.com': { + _name: "HiFeng'Blog", + '.': [ + { + title: '博客', + docs: 'https://docs.rsshub.app/routes/blog#hifeng-blog', + source: ['/'], + target: '/hicairo', + }, + ], + }, +}; diff --git a/lib/v2/hicairo/router.js b/lib/v2/hicairo/router.js new file mode 100644 index 0000000000..574929e02f --- /dev/null +++ b/lib/v2/hicairo/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/', require('./rss')); +}; diff --git a/lib/v2/hicairo/rss.js b/lib/v2/hicairo/rss.js new file mode 100644 index 0000000000..46d8556d60 --- /dev/null +++ b/lib/v2/hicairo/rss.js @@ -0,0 +1,32 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const currentUrl = 'https://www.hicairo.com'; + const response = await got(`${currentUrl}/feed.php`); + const $ = cheerio.load(response.data, { xmlMode: true }); + const title_main = $('channel > title').text(); + const description_main = $('channel > description').text(); + const items = $('channel > item') + .map((_, item) => { + const $item = $(item); + const link = $item.find('link').text(); + const title = $item.find('title').text(); + const description = $item.find('description').text(); + const pubDate = $item.find('pubDate').text(); + return { + link, + pubDate, // no need to normalize because it's from a valid RSS feed + title, + description, + }; + }) + .get(); + + ctx.state.data = { + title: title_main, + description: description_main, + link: currentUrl, + item: items, + }; +}; diff --git a/website/docs/routes/blog.mdx b/website/docs/routes/blog.mdx index 89f06df19a..b2b019e738 100644 --- a/website/docs/routes/blog.mdx +++ b/website/docs/routes/blog.mdx @@ -473,3 +473,9 @@ ### 上周热门 TOP 20 {#zhu-bai-shang-zhou-re-men-top-20} + +## HiFeng'Blog {#Hi-Feng-Blog} + +### 博客 {#Hi-Feng-Blog-bo-ke} + + \ No newline at end of file