//#r "System.Windows.Forms.dll" //#r "fiddler/FiddlerCore.dll" using Fiddler; using System; using System.Windows.Forms; using System.Collections.Generic; using System.IO; using System.Net; using System.Threading; using System.Threading.Tasks; public class Startup { Func<object, Task<object>> _console; Func<object, Task<object>> _html; public async void _print(object text){ if(_console!=null) await _console(text); } public async void _getHtml(object html) { if (_html != null) await _html(html); } public async Task<object> Invoke(dynamic data) { _console = (Func<object, Task<object>>)data.console; _html = (Func<object, Task<object>>)data._html; _print("Started"); FiddlerApplication.Shutdown(); new FiddlerLogic { _beforeRequest = (oS) => { var proxy = oS.oRequest.headers["POverride"]; if (proxy != null) { oS["X-OverrideGateway"] = proxy; } }, _beforeResponse = (oS) => { var response = oS.GetResponseBodyAsString(); _html(response); } }._start(5000); return Task.FromResult("Done"); } } class FiddlerLogic { public Action<Session> _beforeRequest; public Action<Session> _beforeResponse; public void _start(int port=5555) { FiddlerApplication.BeforeRequest += (oS) => _beforeRequest(oS); FiddlerApplication.BeforeResponse += (oS) => _beforeResponse(oS); FiddlerApplication.Startup(port, false, true); } }
var edge = require('edge'); var gui = require('nw.gui'); var async = require('async'); var request = require('request'); var start=Date.now(); var arr=[]; var count=50; var prev=Date.now(); var proxyList = ['160.92.56.41:80']; _init(); for(var i=0; i<count; i++){ arr.push('http://myip.ru/index_small.php') } var i=0; var _node=function(url, c){ console.log(url); var options = { url: url, headers: { 'POverride': proxyList[0] } }; request(options, function(err, response, html){ if(err) console.log(err); var j=_html(html); console.log('Container:', j.find('.network-info tbody>:nth-child(2) td').text()); c(); }); }; async.map(arr, _node, function(){ var ms=Date.now()-start; console.info('Node parse got %f seconds. Mid time: %f. Mid page per second: %f', ms/1000, ms/count, count*1000/ms); } ); /***DEFINITIONS***/ function _html(html){ return $('<div></div>').html(html); }; function _init(){ try{ request=request.defaults({'proxy':'http://localhost:5000'}); gui.App.setProxyConfig("http://localhost:5000"); func = edge.func("fiddler/Main.cs"); func({ console: function(data, callback){ console.log(data); }, _html: function(html, callback){ //var container=_html(html); //console.log('Container:', container, container.find('.network-info tbody>:nth-child(2) td')); } }); } catch(ex){ console.log(ex); } };
Source: https://habr.com/ru/post/273311/