美文网首页
nodejs request使用ss5代理

nodejs request使用ss5代理

作者: lihao_李浩 | 来源:发表于2019-07-19 14:01 被阅读0次

安装依赖

yarn add request socks5-https-client

代码

var request = require('request');
// var Agent = require('socks5-http-client/lib/Agent')
var Agent = require('socks5-https-client/lib/Agent');

request({
    url: 'https://www.instagram.com/',
    strictSSL: true,
    agentClass: Agent,
    agentOptions: {
        socksHost: '45.77.*2.9*',
        socksPort: 8080,
        socksUsername: 'test',
        socksPassword: '12345678'
    },
    headers: {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
        "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36"
    }
}, function (err, res) {
    debugger
    console.log(err || res.body);
});

相关文章

网友评论

      本文标题:nodejs request使用ss5代理

      本文链接:https://www.haomeiwen.com/subject/ptnjlctx.html