Hack Forums
[C#] [SNIPPET]Grabbing proxies - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] [SNIPPET]Grabbing proxies (/showthread.php?tid=2623574)



[SNIPPET]Grabbing proxies - Pussy Cat - Jun 26, 2012

Hey, so this is a function I've written today to use in something I was working on that required proxies. You just pass it the amount of pages you want it to go through(one page contains 50 proxies) and it will return you the list of proxies in IP:PORT format. Maybe it'll be useful for someone.

Code
static List<string> getProxies(int pages)
  {
    string p, t;
    List<string> _prox = new List<string>();
    WebClient wc = new WebClient() { Proxy = null };
    for (int x = 0; x < pages; x++)
    {
    MatchCollection matches = Regex.Matches(wc.DownloadString("http://hidemyass.com/proxy-list/" + x), @"<tr class="".*?""  ?rel="".*?"">([\s\S]+?)</tr>");
    foreach (Match m in matches)
    {
    t = m.Groups[1].Value;
    p = Regex.Match(t, @"<td>\s?([0-9]{3,7})</td>").Groups[1].Value;
    t = Regex.Match(t, "<td><span>(.+?)</span></td>", RegexOptions.IgnoreCase).Groups[1].Value;
    t = Regex.Replace(t, @"<(span|div) style=""display:none"">.+?</(span|div)>", "");
    t = Regex.Replace(t, "</?span[^>]*>", "");
    t = t + ":" + p;
    _prox.Add(t);
    }  
    }
    return _prox;
  }



* - OELABOELA - Jun 27, 2012

I love you! I was about to make this for an register bot, but thank you :)


* - ibloodqman - Jun 27, 2012

thanks for this!! i needed this a while ago but.. thanks


* - kytro3601 - Jul 23, 2012

Its not working for me when I do:

Code
listBox1.Items.Add(getProxies(1));



* - Pussy Cat - Jul 23, 2012

They changed their source again since I posted this, this should be working now

(Jul 14, 2012 04:37 PM)Woozie Wrote:  If anyone is interested this one will work with the new source, it's in C# though.
[Image: IAOc]

Code
static List<string> GetProxy()
  {
    List<string> li = new List<string>();
    string src = new WebClient() { Proxy = null }.DownloadString("http://hidemyass.com/proxy-list/");
    foreach (Match m in Regex.Matches(src, @"<tr class="".*?""  rel=""\d+?"">([\s\S]+?)</style>([\s\S]+?)<td>\s(\d+)</td>"))
    {
    string ws = m.Groups[2].Value;
    foreach (Match _m in Regex.Matches(m.Groups[1].Value, @"\.(.+?)\{(.+?)\}"))
    {
    ws = ws.Replace(string.Format(@"class=""{0}""", _m.Groups[1].Value), string.Format(@"style=""{0}""", _m.Groups[2].Value));
    }
    ws = string.Format("{0}:{1}", Regex.Replace(ws, @"<(div|span) style=""display:none"">.*?</(div|span)>|<[^>]+?>|\s", ""), m.Groups[3].Value);
    li.Add(ws);
    }
    return li;
  }



* - kytro3601 - Jul 25, 2012

(Jul 23, 2012 01:19 PM)Woozie Wrote:  They changed their source again since I posted this, this should be working now

Thanks for the quick fix Woozie :). Gonna implement it into my bots