diff --git a/docs/README.md b/docs/README.md index a37ed335c4..8b66c0fe70 100644 --- a/docs/README.md +++ b/docs/README.md @@ -420,6 +420,8 @@ RSSHub 提供下列 API 接口: + + @@ -2563,7 +2565,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 - + | 文章点击排行 | 文章推荐排行 | 最近更新文章 | | ------------ | ------------ | ------------ | diff --git a/lib/router.js b/lib/router.js index 9e9e35b0aa..3d50138946 100644 --- a/lib/router.js +++ b/lib/router.js @@ -497,6 +497,7 @@ router.get('/bugly/changelog/:platform', require('./routes/tencent/bugly/changel // wechat router.get('/wechat/wasi/:id', require('./routes/tencent/wechat/wasi')); router.get('/wechat/wemp/:id', require('./routes/tencent/wechat/wemp')); +router.get('/wechat/csm/:id', require('./routes/tencent/wechat/csm')); router.get('/wechat/announce', require('./routes/tencent/wechat/announce')); router.get('/wechat/miniprogram/plugins', require('./routes/tencent/wechat/miniprogram/plugins')); diff --git a/lib/routes/tencent/wechat/csm.js b/lib/routes/tencent/wechat/csm.js new file mode 100644 index 0000000000..d351b07fc3 --- /dev/null +++ b/lib/routes/tencent/wechat/csm.js @@ -0,0 +1,63 @@ +const axios = require('../../../utils/axios'); +const date = require('../../../utils/date'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const { id } = ctx.params; + + const link = `https://chuansongme.com/account/${id}`; + + const response = await axios.get(link); + + const $ = cheerio.load(response.data); + + const items = await Promise.all( + $('.feed_item') + .slice(0, 5) + .get() + .map(async (e) => { + const pubDate = date( + `${$(e) + .find('.timestamp') + .text() + .trim()}`, + 8 + ); + + const link = `https://chuansongme.com${$(e) + .find('.question_link') + .attr('href')}`; + + const response = await ctx.cache.tryGet(link, async () => (await axios.get(link)).data); + + const article = cheerio.load(response); + + article('[style="display: none;"], [style=" display: none;"], [style="display: none"]').each((i, e) => { + $(e).remove(); + }); + + const single = { + title: article('#activity-name').text(), + link, + description: article('#js_content').html(), + pubDate, + author: article('#meta_content > span:nth-child(2)').text(), + }; + + return Promise.resolve(single); + }) + ); + + ctx.state.data = { + title: `微信公众号 - ${$('.inline_editor_content') + .first() + .text() + .trim()}`, + link, + description: $('.inline_editor_content') + .last() + .text() + .trim(), + item: items, + }; +};