[JavaScript] 纯文本查看 复制代码 let url = "http://whois.pconline.com.cn/ipJson.jsp";
fetch(url, {
method: 'GET',
// body: null,
redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect
timeout: 10000, //ms
}).then(function (res) {
console.log("Response Headers ============ ");
res.headers.forEach(function (v, i, a) {
console.log(i + " : " + v);
if (i.toLowerCase() == "content-type") charset = v.split("charset=").reverse()[0];
});
return res.buffer();
}).then(function (res) {
console.log("Response Body ============ ");
let body = iconv.decode(Buffer.concat([res]), 'GBK');
console.log("🚀 ~ GetIP ~ body", body)
});
上面代码可以转,无意之间找到 |