Skip to content

使用 got 从 HTML 获取数据时乱码,怎样强制编码 #8854

Answered by shawn8888
shawn8888 asked this question in Q&A
Discussion options

You must be logged in to vote

自己找到答案了:
got加一个参数:responseType: 'buffer',
然后:const $ = cheerio.load((iconv.decode(response.data, 'GBK')));

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sunwgit
Comment options

Answer selected by shawn8888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants