简体   繁体   English

通过request.js使用多个代理

[英]Using multiple proxies via request.js

I am trying to send a list of proxy addresses to requestjs & want it to use first one that's is working. 我正在尝试将代理地址列表发送到requestjs,并希望它使用第一个正在工作的代理地址。 Is it at all possible via request.js 是否完全可以通过request.js

My code is 我的代码是

 var body = '<sample/>';
 request.post({
                url: www.google.com,
                proxy':'http://proxy1:8087;http://proxy2:8080',//need to use multiple proxies here.
                headers: { //We can define headers too
                    'Content-Type': 'text/xml'
                },
                body: body,
                timeout:20000
            }

I am thinking of looping through list of proxies and try to use them one by one. 我正在考虑遍历代理列表,并尝试一一使用。 I am not sure if that would have been an overkill or is the only way possible. 我不确定这是否会造成过度的杀伤力或唯一可行的方法。

requestjs cannot loop through proxies, the best possible option is to use an agent module alongwith it like https://www.npmjs.com/package/pac-proxy-agent requestjs无法遍历代理,最好的选择是与它一起使用代理模块,例如https://www.npmjs.com/package/pac-proxy-agent

But even this module does not iterate through the list for now. 但是,即使此模块目前也不会遍历列表。 The only feasible option is to loop through the list of proxies and use the first one reachable for now. 唯一可行的选择是遍历代理服务器列表,并使用第一个可访问的代理服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM