mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 11:07:54 +08:00
feat: add scboy
This commit is contained in:
@@ -2470,4 +2470,18 @@
|
||||
},
|
||||
],
|
||||
},
|
||||
'scboy.com': {
|
||||
_name: 'scboy 论坛',
|
||||
www: [
|
||||
{
|
||||
title: '帖子',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#scboy',
|
||||
source: '',
|
||||
target: (params, url) => {
|
||||
const id = url.includes('thread') ? url.split('-')[1].split('.')[0] : '';
|
||||
return id ? `/scboy/thread/${id}` : '';
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
11
docs/bbs.md
11
docs/bbs.md
@@ -180,6 +180,17 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
## SCBOY 论坛
|
||||
|
||||
### 帖子
|
||||
|
||||
<Route author="totorowechat" example="/scboy/thread/188673" path="/scboy/thread/:tid" :paramsDesc="['帖子 tid']" radar="1">
|
||||
|
||||
帖子网址如果为 <https://www.scboy.com/?thread-188673.htm> 那么帖子 tid 就是 `1789863`。
|
||||
|
||||
访问水区需要添加环境变量 `SCBOY_BBS_TOKEN`, 详情见部署页面的配置模块。 `SCBOY_BBS_TOKEN`在cookies的`bbs_token`中。
|
||||
</Route>
|
||||
|
||||
## V2EX
|
||||
|
||||
### 最热 / 最新主题
|
||||
|
||||
@@ -182,6 +182,9 @@ const calculateValue = () => {
|
||||
username: envs.DIDA365_USERNAME,
|
||||
password: envs.DIDA365_PASSWORD,
|
||||
},
|
||||
scboy: {
|
||||
token: envs.SCBOY_BBS_TOKEN,
|
||||
},
|
||||
};
|
||||
};
|
||||
calculateValue();
|
||||
|
||||
@@ -3766,4 +3766,7 @@ router.get('/sciencenet/blog/:type?/:time?/:sort?', require('./routes/sciencenet
|
||||
// DailyArt
|
||||
router.get('/dailyart/:language?', require('./routes/dailyart/index'));
|
||||
|
||||
// SCBOY
|
||||
router.get('/scboy/thread/:tid', require('./routes/scboy/thread'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
53
lib/routes/scboy/thread.js
Normal file
53
lib/routes/scboy/thread.js
Normal file
@@ -0,0 +1,53 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const date = require('@/utils/date');
|
||||
const config = require('@/config').value;
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const tid = ctx.params.tid;
|
||||
const link = `https://www.scboy.com/?thread-${tid}.htm`;
|
||||
let cookieString = 'postlist_orderby=desc';
|
||||
if (config.scboy.token) {
|
||||
cookieString = `postlist_orderby=desc; bbs_token=${config.scboy.token}`;
|
||||
}
|
||||
|
||||
const res = await got.get({
|
||||
method: 'get',
|
||||
url: link,
|
||||
responseType: 'buffer',
|
||||
headers: {
|
||||
Cookie: cookieString,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(res.data);
|
||||
const title = $('h4 > span:nth-of-type(1)').text();
|
||||
|
||||
const list = $('li.media.post');
|
||||
const count = [];
|
||||
|
||||
for (let i = 0; i < Math.min(list.length, 30); i++) {
|
||||
count.push(i);
|
||||
}
|
||||
|
||||
const resultItems = await Promise.all(
|
||||
count.map(async (i) => {
|
||||
const each = $(list[i]);
|
||||
const floor = each.find('span.floor-parent').text();
|
||||
const item = {
|
||||
title: `${title} #${floor ? floor : ' 热门回复'}`,
|
||||
link: `https://www.scboy.com/?thread-${tid}`,
|
||||
description: each.find('div.message.mt-1.break-all > div:nth-of-type(1)').html(),
|
||||
author: each.find('username').text(),
|
||||
pubDate: date(each.find('.date').text()),
|
||||
};
|
||||
return Promise.resolve(item);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: title,
|
||||
link: `https://www.scboy.com/?thread-${tid}.htm`,
|
||||
item: resultItems,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user