当前位置:首页>帮助中心>Python爬虫用了高匿名代理ip,为什么还是会封掉本机ip

Python爬虫用了高匿名代理ip,为什么还是会封掉本机ip

发布日期:2020-05-28 09:09:06 来源:雷神HTTP

      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)

}

});

}

用户登录

自动登录 忘记密码?

还没帐号?立即注册

用户注册

图形验证码

短信获取

我已阅读并同意 《用户协议》

已有账号?立即登录

忘记密码

图形验证码

短信获取

返回登录