采集了对方网站,但是返回类型是字符串,怎样才能转为html呢
let headers = {
'Accept':'text/html',
'content-type':'text/xml'
};
let url = 'https://地址不方便透露';
let options = {
url,
encoding: null,
headers:headers
};
// 请求
request(options,function(error, response, body){
var html = iconv.decode(body,'utf-8'); // GBK,utf-8
res.json(html);
})
请求结果如下:
是string类型的,我怎样才能转为html类型呢?
将res.json换成res.send