1.代理可能并不高匿。你可以使爬虫访问您的IP地址,来检测代理是否生效。
2.服务器可能通过请求头中的X-Real-IP、X-Forwarded-For等信息来获取真实ip。可以在发起请求时伪造这些值。
下面是我用于投票的一部分代码(nodejs):
function postRequest(url,data,callback,charset='utf8',cookie){
var proxy = getProxy('https');
console.log("Posting through proxy @ "+proxy)
SA.post(url)
.proxy(proxy)
.set("Cookie",cookie)
.set('User-Agent',randomUA())
.set('X-Forwarded-For',randomIP())
.set('X-Real-IP',randomIP())
.set('Content-Type','application/x-www-form-urlencoded')
.send(data)
.timeout(5000)
.end(function(err,res){
if (typeof(res)!="undefined"){
callback(res);
}else{
console.log("Conect failed, try next proxy ");
postRequest(url,data,callback,null,cookie)
}
});
}