获取免费代理推荐

一些免费到代理地址

http://www.xicidaili.com/nn

https://proxy.l337.tech/txt

http://www.66ip.cn/nm.html

 

function getProxyList() {
    // http://www.66ip.cn/nm.html
    var apiURL = 'http://www.66ip.cn/nmtq.php?getnum=100&isp=0&anonymoustype=0&start=&ports=&export=&ipaddress=&area=0&proxytype=0&api=66ip';
    return new Promise((resolve, reject) => {
        var options = {
            method: 'GET',
            url: apiURL,
            gzip: true,
            encoding: null,
            headers: {
                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
                'Accept-Encoding': 'gzip, deflate',
                'Accept-Language': 'zh-CN,zh;q=0.8,en;q=0.6,zh-TW;q=0.4',
                'User-Agent': 'Mozilla/8.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36',
                'referer': 'http://www.66ip.cn/'
            },
        };
        request(options, function (error, response, body) {
            try {
                if (error) throw error;
                if (/meta.*(charset=gb2312|charset=GBK)/.test(body)) {
                    body = iconv.decode(body, 'gbk');
                }
                var ret = body.match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,4}/g);
                resolve(ret);
            } catch (e) {
                return reject(e);
            }
        });
    })
}

getProxyList().then(function (proxyList) {
    proxyList.forEach(function (proxyurl) {
        request({
            method: 'GET',
            url: 'http://ip.chinaz.com/getip.aspx',
            timeout: 30000,
            encoding: null,
            proxy: 'http://' + proxyurl
        }, function (err, _res, body) {
            if (err) {
                console.error("fail", err.message) 
            } else {
                try {
                    // 将 buffer 转化为字符串
                    body = body.toString();
                    // 序列化
                    body = eval('(' + body + ')')
                    console.log("success", body.address, proxyurl);
                } catch(err) {
                    console.log('fail page');
                } 
            }
        })
    });
}).catch(e => {
    console.log(e);
})

 

转载于:https://www.cnblogs.com/CyLee/p/9211921.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值