feat(route): 支持 xsijishe.com 论坛 rss (#12043)
* 支持司机社论坛 rss * rename sjs to xsijishe * Update docs/bbs.md * Update docs/bbs.md * Update lib/v2/xsijishe/forum.js * Update lib/v2/xsijishe/forum.js * Update lib/v2/xsijishe/forum.js * Update lib/v2/xsijishe/radar.js ---------
This commit is contained in:
parent
53cc4caa79
commit
569c630ca6
14
docs/bbs.md
14
docs/bbs.md
|
|
@ -869,6 +869,20 @@ pageClass: routes
|
|||
|
||||
<Route author="nczitzk" example="/newsmth/account/fef705ec94819a5a87941759e33c0982" path="/newsmth/account/:id" :paramsDesc="['用户 id,可在用户页的 URL 中找到']"/>
|
||||
|
||||
## 司机社
|
||||
|
||||
### 论坛
|
||||
|
||||
<Route author="akynazh" example="/xsijishe/forum/51" path="/xsijishe/forum/:fid" :paramDesc="['子论坛 id']" radar="1">
|
||||
|
||||
::: tip 关于子论坛 id 的获取方法
|
||||
|
||||
`/xsijishe/forum/51` 对应于论坛 <https://xsijishe.com/forum-51-1.html>,这个论坛的 fid 为 51,也就是 `forum-{fid}-1` 中的 fid。
|
||||
|
||||
:::
|
||||
|
||||
</Route>
|
||||
|
||||
## 天涯论坛
|
||||
|
||||
### 子版块
|
||||
|
|
|
|||
|
|
@ -0,0 +1,61 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const baseUrl = 'https://xsijishe.com';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const fid = ctx.params.fid;
|
||||
const url = `${baseUrl}/forum-${fid}-1.html`;
|
||||
const resp = await got(url);
|
||||
const $ = cheerio.load(resp.data);
|
||||
const forumCategory = $('.nex_bkinterls_top .nex_bkinterls_ls a').text();
|
||||
let items = $('[id^="normalthread"]')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const nexAuthorBtms = item.find('.nex_author_btms');
|
||||
const nexForumtitTopA = item.find('.nex_forumtit_top a').first();
|
||||
const nexFtdate = nexAuthorBtms.find('.nex_ftdate');
|
||||
let pubDate;
|
||||
if (nexFtdate.find('span').length > 0) {
|
||||
pubDate = nexFtdate.find('span').attr('title');
|
||||
} else {
|
||||
pubDate = nexFtdate.text().replace('发表于', '');
|
||||
}
|
||||
return {
|
||||
title: nexForumtitTopA.text().trim(),
|
||||
pubDate: parseDate(pubDate.trim()),
|
||||
category: nexAuthorBtms.find('em a').text().trim(),
|
||||
link: baseUrl + '/' + nexForumtitTopA.attr('href'),
|
||||
author: item.find('.nex_threads_author').find('a').text().trim(),
|
||||
};
|
||||
});
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const resp = await got(item.link);
|
||||
const $ = cheerio.load(resp.data);
|
||||
const firstViewBox = $('.t_f').first();
|
||||
|
||||
firstViewBox.find('img').each((_, img) => {
|
||||
img = $(img);
|
||||
if (img.attr('zoomfile')) {
|
||||
img.attr('src', img.attr('zoomfile'));
|
||||
img.removeAttr('zoomfile');
|
||||
img.removeAttr('file');
|
||||
}
|
||||
img.removeAttr('onmouseover');
|
||||
});
|
||||
|
||||
item.description = firstViewBox.html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: `司机社${forumCategory}论坛`,
|
||||
link: url,
|
||||
description: `司机社${forumCategory}论坛`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/forum/:fid': ['akynazh'],
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
'xsijishe.com': {
|
||||
_name: '司机社',
|
||||
'.': [
|
||||
{
|
||||
title: '论坛',
|
||||
docs: 'https://docs.rsshub.app/bbs.html#si-ji-she',
|
||||
source: ['/*'],
|
||||
target: (_, url) => {
|
||||
const re = /forum-(\d+)-/;
|
||||
const res = re.exec(url);
|
||||
if (res) {
|
||||
return `/xsijishe/forum/${res[1]}`;
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/forum/:fid', require('./forum'));
|
||||
};
|
||||
Loading…
Reference in New Issue