From e4107e35a40f14992fb4f455e58442c1d1f7fc6c Mon Sep 17 00:00:00 2001 From: jiangzhh Date: Fri, 15 Dec 2023 15:41:43 +0800 Subject: [PATCH] feat(route): add fxiaoke.com blog --- lib/v2/fxiaoke/crm.js | 62 ++++++++++++++++++++++++++++++++++++ lib/v2/fxiaoke/maintainer.js | 3 ++ lib/v2/fxiaoke/radar.js | 37 +++++++++++++++++++++ lib/v2/fxiaoke/router.js | 3 ++ website/docs/routes/blog.mdx | 10 ++++++ 5 files changed, 115 insertions(+) create mode 100644 lib/v2/fxiaoke/crm.js create mode 100644 lib/v2/fxiaoke/maintainer.js create mode 100644 lib/v2/fxiaoke/radar.js create mode 100644 lib/v2/fxiaoke/router.js diff --git a/lib/v2/fxiaoke/crm.js b/lib/v2/fxiaoke/crm.js new file mode 100644 index 00000000000000..bcfb12906f64d2 --- /dev/null +++ b/lib/v2/fxiaoke/crm.js @@ -0,0 +1,62 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const baseUrl = 'https://www.fxiaoke.com/crm'; +const baseTitle = '纷享销客 CRM'; +const titleMap = new Map([ + ['news', `全部文章 - ${baseTitle}`], + ['blog', `文章干货 - ${baseTitle}`], + ['articles', `CRM 知识 - ${baseTitle}`], + ['about-influence', `纷享动态 - ${baseTitle}`], + ['customers', `签约喜报 - ${baseTitle}`], +]); + +module.exports = async (ctx) => { + const t = ctx.params.type; + const title = titleMap.get(t); + const url = `${baseUrl}/${t}/`; + const resp = await got(url); + const $ = cheerio.load(resp.data); + const desc = $('.meeting').text().trim(); + let items = $('.content-item') + .toArray() + .map((item) => { + item = $(item); + const c1 = item.find('.baike-content-t1'); + const c3 = item.find('.baike-content-t3').find('span'); + return { + title: c1.text().trim(), + pubDate: parseDate(c3.first().text().trim()), + link: item.find('a').attr('href'), + author: c3.last().text().trim(), + }; + }); + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const resp = await got(item.link); + const $ = cheerio.load(resp.data); + const firstViewBox = $('.content-wrapper').first(); + + firstViewBox.find('img').each((_, img) => { + img = $(img); + if (img.attr('zoomfile')) { + img.attr('src', img.attr('zoomfile')); + img.removeAttr('zoomfile'); + img.removeAttr('file'); + } + img.removeAttr('onmouseover'); + }); + + item.description = firstViewBox.html(); + return item; + }) + ) + ); + ctx.state.data = { + title, + link: url, + description: desc, + item: items, + }; +}; diff --git a/lib/v2/fxiaoke/maintainer.js b/lib/v2/fxiaoke/maintainer.js new file mode 100644 index 00000000000000..ded6b214b0c54a --- /dev/null +++ b/lib/v2/fxiaoke/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/crm/:type': ['akynazh'], +}; diff --git a/lib/v2/fxiaoke/radar.js b/lib/v2/fxiaoke/radar.js new file mode 100644 index 00000000000000..3703151465bf4a --- /dev/null +++ b/lib/v2/fxiaoke/radar.js @@ -0,0 +1,37 @@ +module.exports = { + 'fxiaoke.com': { + _name: '纷享销客 CRM', + '.': [ + { + title: '全部文章 - 纷享销客 CRM', + docs: 'https://docs.rsshub.app/routes/blog#fen-xiang-xiao-ke', + source: ['/*'], + target: '/fxiaoke/crm/news', + }, + { + title: '文章干货 - 纷享销客 CRM', + docs: 'https://docs.rsshub.app/routes/blog#fen-xiang-xiao-ke', + source: ['/*'], + target: '/fxiaoke/crm/blog', + }, + { + title: 'CRM 知识 - 纷享销客 CRM', + docs: 'https://docs.rsshub.app/routes/blog#fen-xiang-xiao-ke', + source: ['/*'], + target: '/fxiaoke/crm/articles', + }, + { + title: '纷享动态 - 纷享销客 CRM', + docs: 'https://docs.rsshub.app/routes/blog#fen-xiang-xiao-ke', + source: ['/*'], + target: '/fxiaoke/crm/about-influence', + }, + { + title: '签约喜报 - 纷享销客 CRM', + docs: 'https://docs.rsshub.app/routes/blog#fen-xiang-xiao-ke', + source: ['/*'], + target: '/fxiaoke/crm/customers', + }, + ], + }, +}; diff --git a/lib/v2/fxiaoke/router.js b/lib/v2/fxiaoke/router.js new file mode 100644 index 00000000000000..bd6557d1a5c8b5 --- /dev/null +++ b/lib/v2/fxiaoke/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/crm/:type', require('./crm')); +}; diff --git a/website/docs/routes/blog.mdx b/website/docs/routes/blog.mdx index 635a8ab95fc79a..45ff162740e73a 100644 --- a/website/docs/routes/blog.mdx +++ b/website/docs/routes/blog.mdx @@ -375,6 +375,16 @@ Limit the number of entries to be retrieved by adding `?limit=x` to the end of t | windows | android | tutorial | other | +## 纷享销客 CRM {#fen-xiang-xiao-ke-crm} + +### 文章 {#fen-xiang-xiao-ke-crm-wen-zhang} + + + | 全部文章 | 文章干货 | CRM 知识 | 纷享动态 | 签约喜报 | + | -------- | -------- | -------- | --------------- | --------- | + | news | blog | articles | about-influence | customers | + + ## 虎皮椒 {#hu-pi-jiao} ### 文章 {#hu-pi-jiao-wen-zhang}