mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-13 00:35:57 +08:00
feat: add typora/changelog router (#1122)
This commit is contained in:
@@ -1089,6 +1089,10 @@ GitHub 官方也提供了一些 RSS:
|
|||||||
|
|
||||||
<route name="应用更新" author="DIYgod" example="/xclient/app/sketch" path="/xclient/app/:name" :paramsDesc="['应用名, 可在应用页 URL 中找到']"/>
|
<route name="应用更新" author="DIYgod" example="/xclient/app/sketch" path="/xclient/app/:name" :paramsDesc="['应用名, 可在应用页 URL 中找到']"/>
|
||||||
|
|
||||||
|
### Typora
|
||||||
|
|
||||||
|
<route name="Changelog" author="cnzgray" example="/typora/changelog" path="/typora/changelog"/>
|
||||||
|
|
||||||
## 大学通知
|
## 大学通知
|
||||||
|
|
||||||
### 上海海事大学
|
### 上海海事大学
|
||||||
|
|||||||
@@ -790,6 +790,9 @@ router.get('/eeo/:category?', require('./routes/eeo/index'));
|
|||||||
// 腾讯视频
|
// 腾讯视频
|
||||||
router.get('/tencentvideo/playlist/:id', require('./routes/tencent/video/playlist'));
|
router.get('/tencentvideo/playlist/:id', require('./routes/tencent/video/playlist'));
|
||||||
|
|
||||||
|
// typora
|
||||||
|
router.get('/typora/changelog', require('./routes/typora/changelog'));
|
||||||
|
|
||||||
// TSSstatus
|
// TSSstatus
|
||||||
router.get('/tssstatus/:board/:build', require('./routes/tssstatus'));
|
router.get('/tssstatus/:board/:build', require('./routes/tssstatus'));
|
||||||
|
|
||||||
|
|||||||
70
routes/typora/changelog.js
Normal file
70
routes/typora/changelog.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const host = 'https://support.typora.io/';
|
||||||
|
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: host,
|
||||||
|
headers: {
|
||||||
|
Referer: host,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const parseContent = async (link) => {
|
||||||
|
// Check cache
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return Promise.resolve(JSON.parse(cache));
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: link,
|
||||||
|
headers: {
|
||||||
|
Referer: host,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const title = $('h1').text();
|
||||||
|
const pubDate = new Date($('.post-meta time').text());
|
||||||
|
// const author = $('.post-meta span').text();
|
||||||
|
const html = $('#pagecontainer').html();
|
||||||
|
|
||||||
|
const result = {
|
||||||
|
title: title,
|
||||||
|
link: link,
|
||||||
|
guid: link,
|
||||||
|
pubDate: pubDate,
|
||||||
|
description: html,
|
||||||
|
};
|
||||||
|
|
||||||
|
ctx.cache.set(link, JSON.stringify(result), 3 * 60 * 60);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const items = await Promise.all(
|
||||||
|
$('#content > ul:nth-child(2) > li')
|
||||||
|
.get()
|
||||||
|
.map(async (item) => {
|
||||||
|
const node = $('a', item);
|
||||||
|
const link = node.attr('href');
|
||||||
|
const result = await parseContent(link);
|
||||||
|
|
||||||
|
return Promise.resolve(result);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: 'Typora Changelog',
|
||||||
|
link: host,
|
||||||
|
description: 'Typora Changelog',
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user