feat: add onenote gem add-ins release history (#6241)

This commit is contained in:
Ethan Shen
2020-11-29 19:11:43 +00:00
committed by GitHub
parent fa55b572a1
commit 3c0c68c40e
3 changed files with 59 additions and 0 deletions
+6
View File
@@ -200,6 +200,12 @@ pageClass: routes
<Route author="cielpy" example="/nvidia/webdriverupdate" path="/nvidia/webdriverupdate"/>
## OneNote Gem Add-Ins
### Release History
<Route author="nczitzk" example="/onenotegem/release" path="/onenotegem/release"/>
## PlayStation
### PlayStation 4 系统更新纪录
+3
View File
@@ -3512,6 +3512,9 @@ router.get('/uisdc/news', require('./routes/uisdc/news'));
router.get('/uisdc/zt/:title?', require('./routes/uisdc/zt'));
router.get('/uisdc/topic/:title?/:sort?', require('./routes/uisdc/topic'));
// OneNote Gem Add-Ins
router.get('/onenotegem/release', require('./routes/onenotegem/release'));
// Mind42
router.get('/mind42/tag/:id', require('./routes/mind42/tag'));
router.get('/mind42/search/:keyword', require('./routes/mind42/search'));
+50
View File
@@ -0,0 +1,50 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const rootUrl = 'http://www.onenotegem.com';
const currentUrl = `${rootUrl}/a/release`;
const response = await got({
method: 'get',
url: currentUrl,
});
const $ = cheerio.load(response.data);
const list = $('.paragraph ul li a')
.slice(0, 10)
.map((_, item) => {
item = $(item);
return {
title: item.text(),
link: `${rootUrl}${item.attr('href')}`,
};
})
.get();
const items = await Promise.all(
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = cheerio.load(detailResponse.data);
const title = content('h1.wsite-content-title');
item.description = title.next().next().next().html();
item.pubDate = new Date(title.next().text()).toUTCString();
return item;
})
)
);
ctx.state.data = {
title: 'OneNote Gem Addins Release History',
link: currentUrl,
item: items,
};
};