mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
fix: some bugs in discuz (#3951)
This commit is contained in:
12
docs/bbs.md
12
docs/bbs.md
@@ -16,10 +16,20 @@ pageClass: routes
|
||||
|
||||
## Discuz
|
||||
|
||||
### 通用子版块
|
||||
### 通用子版块-自动检测
|
||||
|
||||
<Route author="junfengP" example="/discuz/http%3a%2f%2fwww.u-share.cn%2fforum.php%3fmod%3dforumdisplay%26fid%3d56" path="/discuz/:link" :paramsDesc="['子版块链接, 需要手动Url编码']"/>
|
||||
|
||||
### 通用子版块-指定版本
|
||||
|
||||
<Route author="junfengP" example="/discuz/x/https%3a%2f%2fwww.52pojie.cn%2fforum-16-1.html" path="/discuz/:ver/:link" :paramsDesc="['discuz版本类型,见下表','子版块链接, 需要手动Url编码']" >
|
||||
|
||||
| Discuz X 系列 | Discuz 7.x 系列 |
|
||||
| ------------- | --------------- |
|
||||
| x | 7 |
|
||||
|
||||
</Route>
|
||||
|
||||
## MCBBS
|
||||
|
||||
### 版块
|
||||
|
||||
@@ -3,3 +3,19 @@ pageClass: routes
|
||||
---
|
||||
|
||||
# BBS
|
||||
|
||||
## Discuz
|
||||
|
||||
### General Subforum - Auto detection
|
||||
|
||||
<Route author="junfengP" example="/discuz/http%3a%2f%2fwww.u-share.cn%2fforum.php%3fmod%3dforumdisplay%26fid%3d56" path="/discuz/:link" :paramsDesc="['link of subforum, require url encoded ']"/>
|
||||
|
||||
### General Subforum - Manual version
|
||||
|
||||
<Route author="junfengP" example="/discuz/x/https%3a%2f%2fwww.52pojie.cn%2fforum-16-1.html" path="/discuz/:ver/:link" :paramsDesc="['discuz version,see below table','link of subforum, require url encoded']" >
|
||||
|
||||
| Discuz X Series | Discuz 7.x Series |
|
||||
| --------------- | ----------------- |
|
||||
| x | 7 |
|
||||
|
||||
</Route>
|
||||
|
||||
@@ -2152,6 +2152,7 @@ router.get('/gbcc/trust', require('./routes/gbcc/trust'));
|
||||
router.get('/apnews/topics/:topic', require('./routes/apnews/topics'));
|
||||
|
||||
// discuz
|
||||
router.get('/discuz/:ver([7|x])/:link(.*)', require('./routes/discuz/discuz'));
|
||||
router.get('/discuz/:link(.*)', require('./routes/discuz/discuz'));
|
||||
|
||||
// China Dialogue 中外对话
|
||||
|
||||
@@ -44,6 +44,7 @@ async function load(baseUrl, itemLink, ctx, charset) {
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let link = ctx.params.link;
|
||||
const ver = ctx.params.ver ? ctx.params.ver.toUpperCase() : undefined;
|
||||
link = link.replace(/:\/\//, ':/').replace(/:\//, '://');
|
||||
|
||||
const response = await got.get(link);
|
||||
@@ -52,18 +53,18 @@ module.exports = async (ctx) => {
|
||||
let charset = 'utf-8';
|
||||
for (const attr of contentType.split(';')) {
|
||||
if (attr.indexOf('charset=') >= 0) {
|
||||
charset = attr.split('=').pop();
|
||||
charset = attr
|
||||
.split('=')
|
||||
.pop()
|
||||
.toLowerCase();
|
||||
}
|
||||
}
|
||||
const responseData = charset === 'utf-8' ? response.data : iconv.decode((await got.get({ url: link, responseType: 'buffer' })).data, charset);
|
||||
const $ = cheerio.load(responseData);
|
||||
const title = $('head > title').text();
|
||||
const version = ver ? 'DISCUZ! ' + ver : $('head > meta[name=generator]').attr('content');
|
||||
let process;
|
||||
if (
|
||||
$('div#footer p em')
|
||||
.text()
|
||||
.startsWith('7')
|
||||
) {
|
||||
if (version.toUpperCase().startsWith('DISCUZ! 7')) {
|
||||
// discuz 7.x 系列
|
||||
// 支持全文抓取,限制抓取页面5个
|
||||
const list = $('tbody[id^="normalthread"] tr')
|
||||
@@ -82,12 +83,7 @@ module.exports = async (ctx) => {
|
||||
return Promise.resolve(Object.assign({}, single, detail));
|
||||
})
|
||||
);
|
||||
} else if (
|
||||
$('div#frt p em')
|
||||
.text()
|
||||
.toUpperCase()
|
||||
.startsWith('X')
|
||||
) {
|
||||
} else if (version.toUpperCase().startsWith('DISCUZ! X')) {
|
||||
// discuz X 系列
|
||||
// 支持全文抓取,限制抓取页面5个
|
||||
const list = $('tbody[id^="normalthread"] tr')
|
||||
|
||||
Reference in New Issue
Block a user