superagent-charset-esm
介绍
一个superagent插件,用于设置charset
,可用于爬取非unicode
中文页面。
作用和superagent-charset一致,这是一个esm+typescript
的版本。
安装
npm i superagent-charset-esm -S
使用说明
import superagent from "superagent";
import { superagentCharset } from "superagent-charset-esm";
const req = superagent.get('http://basic.10jqka.com.cn/000651/worth.html')
.parse(superagentCharset('gbk')) // set the charset
.buffer(true) // to remove the warning from superagent: A custom superagent parser has been set, but buffering strategy for the parser hasn't been configured.
const res = await req
const m = res.text.match(/格力/)