diff --git a/docs/program-update.md b/docs/program-update.md index 57cc140916..91114ab09a 100644 --- a/docs/program-update.md +++ b/docs/program-update.md @@ -354,6 +354,18 @@ pageClass: routes +## Shuax + +### Project + + + +| MouseInc | Chrome | Edge | +| -------- | ------ | ---- | +| mouseinc | chrome | edge | + + + ## simpread ### 消息通知 diff --git a/lib/router.js b/lib/router.js index c62a3af629..3a8160ab13 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3933,6 +3933,9 @@ router.get('/tianyancha/hot', require('./routes/tianyancha/hot')); // King Arthur router.get('/kingarthur/:type', require('./routes/kingarthur/index')); +// Shuax +router.get('/shuax/project/:name?', require('./routes/shuax/project')); + // BioOne router.get('/bioone/featured', require('./routes/bioone/featured')); diff --git a/lib/routes/shuax/project.js b/lib/routes/shuax/project.js new file mode 100644 index 0000000000..f38fb33aa5 --- /dev/null +++ b/lib/routes/shuax/project.js @@ -0,0 +1,37 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const name = ctx.params.name || 'mouseinc'; + + const rootUrl = 'https://shuax.com'; + const currentUrl = `${rootUrl}/project/${name}`; + const response = await got({ + method: 'get', + url: currentUrl, + }); + + const $ = cheerio.load(response.data); + + $('.love-box').remove(); + + const title = $('title').text(); + + ctx.state.data = { + title: `${title.split(' ')[0]} - 耍下`, + link: currentUrl, + item: [ + { + link: currentUrl, + title: title.replace(' – 耍下', ''), + description: $('#page-content').html(), + pubDate: new Date( + response.data + .match(/\d{4}年\d+月\d+日/)[0] + .replace(/年|月/g, '-') + .replace('日', '') + ).toUTCString(), + }, + ], + }; +};