fix: creaders 解码错误 (#5853)
This commit is contained in:
parent
af371a2e6a
commit
4dfcd8cdeb
|
|
@ -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'));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue