// https://www.iqiyi.com/v_19rs789v28.html
var fs = require('fs');
var https = require('https');
var option={
rejectUnauthorized: false,
hostname:'www.iqiyi.com',
path:'/',
headers:{
'Accept':'*/*',
'Accept-Encoding':'utf-8', //这里设置返回的编码方式 设置其他的会是乱码
'Accept-Language':'zh-CN,zh;q=0.8',
'Connection':'keep-alive',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
}
};
https.get(option,function(res){
var chunks = [];
res.on('data',function(chunk){
chunks.push(chunk);
})
res.on('end',function(){
// console.log(Buffer.concat(chunks).toString());
fs.writeFileSync('test.html', Buffer.concat(chunks).toString());
})
})
node.js https 模块设置请求头等信息
最新推荐文章于 2024-06-11 00:00:00 发布