forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): 支持 xsijishe.com 论坛 rss (DIYgod#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 ---------
- Loading branch information
Jack Bryant
authored
Mar 7, 2023
1 parent
53cc4ca
commit 569c630
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
'/forum/:fid': ['akynazh'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]}`; | ||
} | ||
}, | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function (router) { | ||
router.get('/forum/:fid', require('./forum')); | ||
}; |