fix: full text error in discuz (#3880)

This commit is contained in:
junfengP 2020-02-04 16:32:45 +08:00 committed by GitHub
parent a733f1a7c3
commit 40aa69ff0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -25,11 +25,14 @@ async function load(baseUrl, itemLink, ctx, charset) {
// 处理编码问题
let responseData;
if (charset === 'utf-8') {
responseData = await got.get(itemLink).data;
responseData = (await got.get(itemLink)).data;
} else {
responseData = iconv.decode((await got.get({ url: itemLink, responseType: 'buffer' })).data, charset);
}
if (!responseData) {
const description = '获取详细内容失败';
return { description };
}
const $ = cheerio.load(responseData);
// 只抓取论坛1楼消息
const description = $('div#postlist div[id^=post] td[id^=postmessage]')