当尝试在node.js请求模块中使用代理时,出现以下错误:
Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND http http:80
function doVote(username, captchaKey, proxy, csrf){
console.log(proxy);
rp({
uri: "<url>",
proxy: "http://" + proxy,
method: 'POST',
family: 4,
form: {
"username": username
},
headers: {
'User-Agent': "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
}}).then(body => {
console.log(body);
console.log(`Site returned Response Code ${httpResponse.statusCode}`)
if(body.includes("The CAPTCHA needs to be solved.")){
console.log("Couldn't send vote!");
} else {
console.log("Voted!");
}
}).catch(err => {
console.log("===================================");
console.log(err);
console.log("===================================");
});
}
我基本上希望将带有用户名的请求发送到网站。 谢谢!