一、superagent的npm地址:superagent - npm (npmjs.com)
二、代码示例
const superagent = require("superagent");
const fs = require("fs");
async function writeFile(html:string){
fs.writeFileSync('index.html',html,"utf-8");
}
async function getHtml(){
let htmlObj = await superagent.get("www.baidu.com");
let html:string = htmlObj.text;
await writeFile(html);
console.log(html);
return html;
}
getHtml();