fix: creaders 解码错误 (#5853)

This commit is contained in:
Henry Wang 2020-10-10 14:29:51 +01:00 committed by GitHub
parent af371a2e6a
commit 4dfcd8cdeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -4,10 +4,11 @@ const iconv = require('iconv-lite');
module.exports = async (ctx) => {
const currentUrl = 'http://news.creaders.net/headline/';
const response = await got({
method: 'get',
url: currentUrl,
const response = await got.get(currentUrl, {
responseType: 'buffer',
});
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
const list = $('ul.newslist li')
.slice(0, 10)
@ -26,9 +27,8 @@ module.exports = async (ctx) => {
list.map(
async (item) =>
await ctx.cache.tryGet(item.link, async () => {
const res = await got({
method: 'get',
url: item.link,
const res = await got.get(item.link, {
responseType: 'buffer',
});
const content = cheerio.load(iconv.decode(res.data, 'gbk'));