Skip to content

Commit

Permalink
Test update
Browse files Browse the repository at this point in the history
  • Loading branch information
postworthy committed Feb 6, 2014
1 parent c06001b commit e0be521
Show file tree
Hide file tree
Showing 26 changed files with 20,375 additions and 7 deletions.
37 changes: 30 additions & 7 deletions Tests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Tests
Expand All @@ -14,7 +15,7 @@ class Program
{
static void Main(string[] args)
{
RunParallel(1, "https://check.torproject.org/");
RunParallel(10, "https://check.torproject.org/");


// wait until the user presses enter
Expand All @@ -38,24 +39,46 @@ private static void RunParallel(int count, string url)
//This Can be Socks4 or Socks5
ProxyConfig.SocksVersion.Five
));
Enumerable.Range(1, count).ToList().AsParallel().ForAll(new Action<int>(x =>
Enumerable.Range(0, count).ToList().ForEach(new Action<int>(x =>
{
if (x != 0) Thread.Sleep(6000);
WebClient client = new WebClient();
//client.Proxy = proxy.IsActive() ? proxy : null;
client.Proxy = proxy;
string html = client.DownloadString(url);
var doc = new HtmlAgilityPack.HtmlDocument();
var html = client.DownloadString(url);
doc.LoadHtml(html);
var nodes = doc.DocumentNode.SelectNodes("//p/strong");
IPAddress ip;
foreach(var node in nodes)
{
if(IPAddress.TryParse(node.InnerText, out ip))
{

lock (locker)
{
Console.WriteLine(x + ":::::::::::::::::::::");
Console.WriteLine("");
if (html.Contains("Congratulations. This browser is configured to use Tor."))
Console.WriteLine("Connected through Tor with IP: " + ip.ToString());
else
Console.Write("Not connected through Tor with IP: " + ip.ToString());
Console.WriteLine("");
Console.WriteLine(x + ":::::::::::::::::::::");
}
return;
}
}

lock (locker)
{
Console.WriteLine(x + ":::::::::::::::::::::");
Console.WriteLine("");
if (html.Contains("Congratulations. This browser is configured to use Tor."))
Console.WriteLine("Connected through Tor.");
else
Console.Write("Not connected through Tor.");
Console.Write("IP not found");
Console.WriteLine("");
Console.WriteLine(x + ":::::::::::::::::::::");
}

}));
}
}
Expand Down
4 changes: 4 additions & 0 deletions Tests/Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="HtmlAgilityPack">
<HintPath>..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -47,6 +50,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SocksWebProxy\SocksWebProxy.csproj">
Expand Down
4 changes: 4 additions & 0 deletions Tests/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="HtmlAgilityPack" version="1.4.6" targetFramework="net451" />
</packages>
Binary file added packages/HtmlAgilityPack.1.4.6/HAPIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions packages/HtmlAgilityPack.1.4.6/HtmlAgilityPack.1.4.6.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>HtmlAgilityPack</id>
<version>1.4.6</version>
<title>HtmlAgilityPack</title>
<authors>Simon Mourrier, Jeff Klawiter</authors>
<owners>Simon Mourrier, Jeff Klawiter</owners>
<licenseUrl>http://htmlagilitypack.codeplex.com/license</licenseUrl>
<projectUrl>http://htmlagilitypack.codeplex.com/</projectUrl>
<iconUrl>http://blog.j-maxx.net/HAPIcon.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).</description>
<summary>This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams).</summary>
<releaseNotes />
<copyright />
<language />
<tags>HTML parse crawler spider linq</tags>
</metadata>
</package>
Binary file not shown.
Loading

0 comments on commit e0be521

Please sign in to comment.