-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiangzhh
committed
Dec 15, 2023
1 parent
aef347b
commit e4107e3
Showing
5 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/crm/:type': ['akynazh'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (router) { | ||
router.get('/crm/:type', require('./crm')); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters