1. <rp id="c4hsd"></rp>
          1. <button id="c4hsd"><acronym id="c4hsd"><input id="c4hsd"></input></acronym></button>
          2. <tbody id="c4hsd"></tbody>

            <dd id="c4hsd"><pre id="c4hsd"></pre></dd>

              1. <th id="c4hsd"></th>
              2. <s id="c4hsd"><object id="c4hsd"></object></s>

                    [ 登錄 ] - [ 注冊 ] | 代碼示例DEMO | IP測試視頻 |
                    NodeJS代碼調用示例·Https代理(API)
                    
                    /**
                     * 請確保安裝了request和bluebird兩個模塊
                     * 安裝模塊:打開NODEJS-->輸入npm install request-->輸入npm install bluebird
                     **/
                     
                    var request = require("request");
                    var Promise = require("bluebird");
                    
                    // 請填寫無憂代理訂單號
                    var order = 'please-input-your-order-here';
                    // 要測試的網址
                    var targetURL = 'http://pv.sohu.com/cityjson?ie=utf-8';
                    // 請求超時時間
                    var timeout = 8000;
                    // 測試次數
                    var testTime = 5;
                    // 間隔多少毫秒調用一次接口
                    var sleepTime = 5000;
                    
                    var apiURL = 'http://api.ip.data5u.com/dynamic/get.html?order=' + order + '&sep=3';
                    
                    console.log('>>>> start test dynamic ip');
                    
                    function getProxyList() {
                        return new Promise((resolve, reject) => {
                            var options = {
                                method: 'GET',
                                url: apiURL,
                                gzip: true,
                                encoding: null,
                                headers: {},
                            };
                    
                            request(options, function (error, response, body) {
                                try {
                                    if (error) throw error;
                                    var ret = (body + '').match(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5}/g);
                                    resolve(ret);
                                } catch (e) {
                                    return reject(e);
                                }
                            });
                        });
                    }
                    
                    function execute(){
                    	getProxyList().then(function (proxyList) {
                    		var targetOptions = {
                    			method: 'GET',
                    			url: targetURL,
                    			timeout: timeout,
                    			encoding: null,
                    		};
                    
                    		proxyList.forEach(function (proxyurl) {
                    			console.log(`* testing `);
                    			var startTimestamp = (new Date()).valueOf();
                    			targetOptions.proxy = 'http://' + proxyurl;
                    			request(targetOptions, function (error, response, body) {
                    				try {
                    					if (error) throw error;
                    					body = body.toString();
                    					var endTimestamp = (new Date()).valueOf();
                    					console.log('  > time ' + (endTimestamp - startTimestamp) + 'ms ' + body);
                    				} catch (e) {
                    					console.error(e);
                    				}
                    			});
                    		});
                    	}).catch(e => {
                    		console.log(e);
                    	})
                    }
                    
                    // 定時執行
                    var interval = setInterval(function(){
                    	if(testTime > 0){
                    		execute()
                    	} else {
                    		clearInterval(interval);
                    		console.log('<<<< end test dynamic ip');
                    	}
                    	testTime = testTime - 1;
                    }, sleepTime);
                    
                    
                    
                    NodeJS代碼調用示例·Https代理(動態轉發)
                    
                    /**
                     * 先運行npm install moment安裝moment模塊,運行npm install crypto安裝crypto模塊
                     */
                    
                    var request = require("request");
                    var moment = require("moment");
                    var crypto = require('crypto');
                    
                    var options = {};
                    
                    
                    var raw = "替換成你的IP提取碼:替換成你的動態轉發密碼";
                    
                    options.method = "GET";
                    options.url = "https://www.so.com";
                    options.headers = {
                        "Proxy-Authorization": "Basic " + new Buffer(raw).toString('base64')
                    };
                    options.rejectUnauthorized=false;
                    options.proxy = 'http://tunnel.data5u.com:56789';
                    
                    var startTimestamp = (new Date()).valueOf();
                    request(options, function (error, response, body) {
                    	try {
                    		if (error) throw error;
                    		body = body.toString();
                    		var endTimestamp = (new Date()).valueOf();
                    		console.log('  > time ' + (endTimestamp - startTimestamp) + 'ms ' + body);
                    	} catch (e) {
                    		console.error(e);
                    	}
                    });
                    
                    
                    電話:4007-745-096
                    QQ:
                    周一至周日8:30-18:00 技術部電話熱線
                    久久夜色精品国产噜噜亚洲AV_老妇女性较大毛片_888亚洲欧美国产va在线播放_超碰人人透人人爽人人看