mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: 简阅(simpread) changelog
This commit is contained in:
@@ -439,3 +439,6 @@ pageClass: routes
|
||||
### 消息通知
|
||||
|
||||
<Route author="zytomorrow" example="/simpread/notice" path="/yuanliao/notice">
|
||||
|
||||
### 更新日志
|
||||
<Route author="zytomorrow" example="/simpread/changelog" path="/yuanliao/changelog">
|
||||
|
||||
+4
-1
@@ -3780,7 +3780,10 @@ router.get('/nace/blog/:sort?', require('./routes/nace/blog'));
|
||||
// Caixin Latest
|
||||
router.get('/caixin/latest', require('./routes/caixin/latest'));
|
||||
|
||||
// SimpRead
|
||||
// SimpRead-消息通知
|
||||
router.get('/simpread/notice', require('./routes/simpread/notice'));
|
||||
|
||||
// SimpRead-更新日志
|
||||
router.get('/simpread/changelog', require('./routes/simpread/changelog'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const url = 'https://simpread.pro/changelog.html';
|
||||
const response = await got.get(url);
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
ctx.state.data = {
|
||||
title: 'SimpRead 更新日志',
|
||||
link: url,
|
||||
description: $('body > div.container.changelog > div.desc').html(),
|
||||
item: $('.version')
|
||||
.map((index, item) => {
|
||||
const year = $(item).find('.year').html();
|
||||
const month_day = $(item).find('.day').html();
|
||||
let version = '';
|
||||
let detail = '';
|
||||
|
||||
// 结构异化-收个version与后续version不同级
|
||||
if (index === 0) {
|
||||
// 版本名称处理
|
||||
version = $($(item).find('.num > a')[0]).clone().children().remove().end().text();
|
||||
// detail处理
|
||||
detail = $($(item).find('.details')[0]);
|
||||
} else {
|
||||
// 版本名称处理
|
||||
version = $(item).find('.num > a').clone().children().remove().end().text();
|
||||
// detail处理
|
||||
detail = $(item).find('.details');
|
||||
}
|
||||
if (version === '') {
|
||||
version = $(item).find('.num').clone().children().remove().end().text();
|
||||
}
|
||||
let version_type = $(item).find('.num > a > i').attr('class');
|
||||
// 部分结构不一致处理
|
||||
if (version_type === undefined) {
|
||||
version_type = $(item).find('.num > i').attr('class');
|
||||
}
|
||||
if (version_type.indexOf('chrome') !== -1) {
|
||||
version_type = 'Chrome';
|
||||
}
|
||||
if (version_type.indexOf('apple') !== -1) {
|
||||
version_type = 'Safari';
|
||||
}
|
||||
if (version_type.indexOf('code') !== -1) {
|
||||
version_type = 'UserScript';
|
||||
}
|
||||
if (version_type.indexOf('firefox') !== -1) {
|
||||
version_type = 'Firefox';
|
||||
}
|
||||
|
||||
$(detail)
|
||||
.find('li')
|
||||
.map((index, item) => {
|
||||
const level = $(item).find('span').attr('class');
|
||||
if (level !== undefined) {
|
||||
if (level.indexOf('empty') !== -1) {
|
||||
$(item).wrap('<ul></ul>');
|
||||
} else {
|
||||
$(item).find('span').append('<br/>');
|
||||
}
|
||||
}
|
||||
return {};
|
||||
});
|
||||
|
||||
return {
|
||||
description: $(detail).html(),
|
||||
link: url,
|
||||
pubDate: `${year}-${month_day.replace('.', '-')} 00:00:00 GMT`,
|
||||
title: `${version_type}${version}`,
|
||||
author: 'SimpRead',
|
||||
};
|
||||
})
|
||||
.get(),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user