mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 14:07:54 +08:00
feat: 支持 Saraba1st 帖子订阅 (#2011)
This commit is contained in:
@@ -450,6 +450,14 @@
|
||||
|
||||
<Route name="帖子" author="xyqfer" example="/nga/post/15939161" path="/nga/post/:tid" :paramsDesc="['帖子 id, 可在帖子 URL 找到']"/>
|
||||
|
||||
# Saraba1st
|
||||
|
||||
<Route name="帖子" author="zengxs" example="/saraba1st/thread/1789863" path="/saraba1st/thread/:tid" :paramsDesc="['帖子 id']">
|
||||
|
||||
帖子网址如果为 <https://bbs.saraba1st.com/2b/thread-1789863-1-1.html> 那么帖子 id 就是 `1789863`。
|
||||
|
||||
</Route>
|
||||
|
||||
## Facebook
|
||||
|
||||
<Route name="粉絲專頁" author="maple3142" example="/facebook/page/SonetPCR" path="/facebook/page/:id" :paramsDesc="['專頁 id']"/>
|
||||
|
||||
@@ -1293,4 +1293,7 @@ router.get('/ps/list/:gridName', require('./routes/ps/list'));
|
||||
// 毕马威
|
||||
router.get('/kpmg/insights', require('./routes/kpmg/insights'));
|
||||
|
||||
// Saraba1st
|
||||
router.get('/saraba1st/thread/:tid', require('./routes/saraba1st/thread'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
47
lib/routes/saraba1st/thread.js
Normal file
47
lib/routes/saraba1st/thread.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const url = require('url');
|
||||
const axios = require('../../utils/axios');
|
||||
const cheerio = require('cheerio');
|
||||
const date = require('../../utils/date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const tid = ctx.params.tid;
|
||||
|
||||
const res = await axios.get('https://bbs.saraba1st.com/2b/forum.php', {
|
||||
params: {
|
||||
mod: 'viewthread',
|
||||
tid: tid,
|
||||
ordertype: 1,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(res.data);
|
||||
const title = $('#thread_subject').text();
|
||||
|
||||
const list = $('#postlist > div[id^=post_]:not(:first-of-type)');
|
||||
const count = [];
|
||||
|
||||
for (let i = 0; i < Math.min(list.length, 10); i++) {
|
||||
count.push(i);
|
||||
}
|
||||
const resultItems = await Promise.all(
|
||||
count.map(async (i) => {
|
||||
const each = $(list[i]);
|
||||
const floor = each.find('td.plc .pi a > em').text();
|
||||
const floorUrl = each.find('td.plc .pi a').attr('href');
|
||||
const item = {
|
||||
title: `${title} #${floor}`,
|
||||
link: url.resolve('https://bbs.saraba1st.com/2b/', floorUrl),
|
||||
description: each.find('td.t_f').html(),
|
||||
author: each.find('.authi .xw1').text(),
|
||||
pubDate: date(each.find('.authi em').text()),
|
||||
};
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `Stage1 论坛 - ${title}`,
|
||||
link: `https://bbs.saraba1st.com/2b/thread-${tid}-1-1.html`,
|
||||
item: resultItems,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user