feat(route): add shuax 项目 (#7025)

Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
Ethan Shen
2021-03-02 01:59:03 -05:00
committed by GitHub
co-authored by NeverBehave
parent d2abeb9883
commit e025857586
3 changed files with 52 additions and 0 deletions
+12
View File
@@ -354,6 +354,18 @@ pageClass: routes
<Route author="nczitzk" example="/sesame/release_notes" path="/sesame/release_notes"/>
## Shuax
### Project
<Route author="nczitzk" example="/shuax/project/chrome" path="/shuax/project" :paramsDesc="['项目名,见下表,默认为 MouseInc']">
| MouseInc | Chrome | Edge |
| -------- | ------ | ---- |
| mouseinc | chrome | edge |
</Route>
## simpread
### 消息通知
+3
View File
@@ -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'));
+37
View File
@@ -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(),
},
],
};
};