Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

[SNIP] HideMyAss Proxy Grabber

Wrote this for this thread yesterday: https://hackforums.net/showthread.php?tid=2649418

Function:
PHP Code

<?php 
public static string[] grabProxy(string source)
  {
    
// Credits: Soft2050
    
var proxies = new List<string>();
    foreach (Match 
m in Regex.Matches(source, @"<td><span>([\s\S]*?)(\d+)</td>"))
    {
    
string port = m.Groups[2].Value;
    
string ip = m.Groups[1].Value;
    
ip = Regex.Replace(ip, @"(<(div|span) style=""display:none"">\d+.*?>|<.*?>)", "").Trim();
    
proxies.Add(string.Concat(ip, ":", port));
    }
    return 
proxies.ToArray();
  } 

Usage:
PHP Code

<?php 
static void Main(string[] args)
  {

    
WebClient wc = new WebClient();

    
string[] proxyList = grabProxy(wc.DownloadString("http://hidemyass.com/proxy-list/"));

    Array.ForEach(
proxyList, s => Console.WriteLine(s));

    
Console.ReadKey();

  } 

Edit: I just made a little function that will let you grab proxies upto (x) Pages specified by you:

PHP Code

<?php 
public static string[] grabHMAProxies(int uptoPages)
  {
    
// Credits: Soft2050
    
WebClient wc = new WebClient();
    var 
proxies = new List<string>();
    for (
int i = 1; i <= uptoPages; i++)
    {
    
proxies.AddRange(grabProxy(wc.DownloadString(string.Format("http://hidemyass.com/proxy-list/{0}", i))));
    }
    return 
proxies.ToArray();
  } 
Ever thought of making your function get all the proxies from all the pages by the way ? Instead of just the selected page?

Just keep scanning pages from http://hidemyass.com/proxy-list/1 till it contains no more Regex matches (proxies).
Hehe, i did that already before your reply. You might have not seen the last function i guess 😉

[Image: cAGPk.png]

Although in that you have to specify end page 🙂
Wow, this seems really cool. It would be helpful if you could add comments explaining what the code does for beginner coders like myself. 👍
Ok, i am not so good at explaining but i tried what i could do:
PHP Code

<?php 
public static string[] grabProxy(string source)
{
    
// Credits: Soft2050
    
var proxies = new List<string>(); // creates a new list of string to return later
    
foreach (Match m in Regex.Matches(source, @"<td><span>([\s\S]*?)(\d+)</td>"))
    {
    
string port = m.Groups[2].Value;
    
string ip = m.Groups[1].Value;
    
ip = Regex.Replace(ip, @"(<(div|span) style=""display:none"">\d+.*?>|<.*?>)", "").Trim(); // replace extra html tags and hma's hidden divs from source
    
proxies.Add(string.Concat(ip, ":", port)); // add the ip address in a combined form of ip:port
    
}
    return 
proxies.ToArray(); // convert list of string to array and return it back
} 

PHP Code

<?php 
public static string[] grabHMAProxies(int uptoPages)
{
    
// Credits: Soft2050
    
WebClient wc = new WebClient(); // initialize a webclient to download source later, you could use your method of webrequest by replacing the DownloadString method in the below code
    
var proxies = new List<string>(); // creates a new list of string to return later
    
for (int i = 1; i <= uptoPages; i++) // loop until it added proxies from pages from 1 to uptoPages
    
{
    
proxies.AddRange(grabProxy(wc.DownloadString(string.Format("http://hidemyass.com/proxy-list/{0}", i)))); // AddRange - Adds a array to Array which is being returned by grabProxy function
    
}
    return 
proxies.ToArray(); // convert list of string to array and return it back
} 
Hope it helps
Posted the same thing few weeks ago, I guess the thread just got lost in old threads :\
https://hackforums.net/showthread.php?tid=2623574


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by SMS4VERIFAug 4, 2017 07:13 PM 1 412 Aug 4, 2017 07:13 PM
Last Post: Ninja
[.NET] by Noob3Nov 20, 2016 12:47 PM 15 1,078 Nov 20, 2016 12:47 PM
Last Post: Ninja
[Python] by ExoticModzV1Mar 3, 2016 09:53 AM 14 569 Mar 3, 2016 09:53 AM
Last Post: bet4r00t