コード例 #1
0
        public void GetProxy(string url) // GetProxy downloads the URL site data via HTTP and uses regex to extract proxies
        {
            MyWebClient wc = new MyWebClient();

            try
            {
                string data = wc.DownloadString(url);

                string pattern = @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\:\d{1,5}";

                MatchCollection matches = Regex.Matches(data, pattern);
                if (matches.Count > 0)
                {
                    string prox = "";
                    foreach (Match match in matches)
                    {
                        prox = prox + match.Groups[0].Value + Environment.NewLine;
                        count++;
                    }
                    LABEL_NumberOfProxies.Text = count.ToString();
                    TB_Proxies.AppendText(prox);
                    goodURLS.Add(url);
                }
                wc.Dispose();
            }
            catch (Exception)
            {
                wc.Dispose();
            }
        }
コード例 #2
0
        private async void BTN_Gather_Click(object sender, EventArgs e) // Loop through the sources list & call 'GetProxy' for each URL
        {
            count = 0;
            BTN_Gather.Enabled = false;
            TB_Proxies.Clear();
            try
            {
                using (StreamReader sr = new StreamReader(TB_Sources.Text))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        await Task.Run(() => GetProxy(line));

                        sourceCount--;
                        LABEL_NumberOfSources.Text = sourceCount.ToString();
                    }
                }
            }
            catch (Exception)
            {
                TB_Sources.Text = "NO SOURCES SELECTED";
            }
        }