C# laat gevonden ip adressen in listbox zien en gebruik ip's

Pagina: 1
Acties:
  • 800 views

Onderwerpen

Vraag


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Ik maak een proxyscraper in Nu wil ik alleen nog dat de gevonden proxys in me listbox worden getoond, want nu zijn ze alleen nog maar te zien in een txt file.

En dat de gevonden proxies gebruikt kunnen worden in een webbrowser control misschien door de textfile te linken met een webbrowser maar ik heb geen idee hoe ik dat kan doen en of dat mogelijk is om die ip adressen gerandomized te kunnen gebruiken in een webbrowser. Kan iemand me misschien verder helpen?


Dit is mijn code:

C#:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace YoutubeProxy
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string[] querys = { "fresh proxies", "pastebin proxies", "grayhatforum proxylist", "pastebin proxylist", ".txt proxylist", "pastebin proxy ip port" };

            label1.Text = "Proxyscraper";
            int count = 15;//pages to scrape (all on first page npt looping this time)
            Regex linkRegex = new Regex("<a href=\"(.*?)\" h=");
            Regex proxyRegex = new Regex(@"\d{1,3}(\.\d{1,3}){3}:\d{1,5}");
            Regex proxyRegex2 = new Regex(@"\d{1,3}(\.\d{1,3}){3}</td><td>\d{1,5}");
            WebClient webClient = new WebClient();
            List<string> alreadyFound = new List<string>();
            string filename = "scraped_proxylist.txt";
            File.WriteAllText(filename, "");
            int counter = 0;
            foreach (string tofind in querys)
            {
                string url = "https://www.bing.com/search?q=" + tofind + "\"&count=#count#";
                try
                {
                    string code = webClient.DownloadString(url.Replace("#count#", count.ToString()));
                    MatchCollection matches1 = linkRegex.Matches(code);
                    foreach (Match match in matches1)
                    {
                        try
                        {
                            string s = match.Groups[1].Value;

                            if (s.StartsWith("http") & !s.Contains("amp") & !s.Contains("microsoft"))//amp & microsoft to avoid shit from Bing
                            {
                                string html = webClient.DownloadString(s);
                                MatchCollection matches = proxyRegex.Matches(html);
                                foreach (Match m in matches)
                                {
                                    string proxy = m.Groups[0].Value;
                                    if (!alreadyFound.Contains(proxy))
                                    {
                                        counter++;
                                        alreadyFound.Add(proxy);
                                        listBox1.Items.Add(proxy);
                                        File.AppendAllText(filename, proxy + Environment.NewLine);
                                    }
                                }
                                matches = proxyRegex2.Matches(html);
                                foreach (Match m in matches)
                                {
                                    string proxy = m.Groups[0].Value.Replace("</td><td>", ":");
                                    if (!alreadyFound.Contains(proxy))
                                    {
                                        counter++;
                                        alreadyFound.Add(proxy);
                                        listBox1.Items.Add(proxy);
                                        File.AppendAllText(filename, proxy + Environment.NewLine);
                                    }
                                }
                                label1.Text = "ProxyScraper " + "\"" + tofind + "\" Proxys = " + counter + " Url: " + s;
                            }
                        }
                        catch { }
                    }
                }
                catch { }
            }
            listBox1.Items.Add("Done!");
            label1.Text = "Proxyscraper" + counter + " proxies found.";
            while (true) { }
        }
    }
}


Zal iemand me verder op weg kunnen helpen?

Alvast bedankt :)

[ Voor 0% gewijzigd door RobIII op 16-08-2019 17:10 . Reden: Code tags gefixed ]

Alle reacties


Acties:
  • 0 Henk 'm!

  • Kheos
  • Registratie: Juni 2011
  • Laatst online: 18:24

Kheos

FP ProMod
Verwijderd schreef op vrijdag 16 augustus 2019 @ 17:01:
Ik maak een proxyscraper in Nu wil ik alleen nog dat de gevonden proxys in me listbox worden getoond, want nu zijn ze alleen nog maar te zien in een txt file.

En dat de gevonden proxies gebruikt kunnen worden in een webbrowser control misschien door de textfile te linken met een webbrowser maar ik heb geen idee hoe ik dat kan doen en of dat mogelijk is om die ip adressen gerandomized te kunnen gebruiken in een webbrowser. Kan iemand me misschien verder helpen?


Dit is mijn code:

code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace YoutubeProxy
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string[] querys = { "fresh proxies", "pastebin proxies", "grayhatforum proxylist", "pastebin proxylist", ".txt proxylist", "pastebin proxy ip port" };

            label1.Text = "Proxyscraper";
            int count = 15;//pages to scrape (all on first page npt looping this time)
            Regex linkRegex = new Regex("<a href=\"(.*?)\" h=");
            Regex proxyRegex = new Regex(@"\d{1,3}(\.\d{1,3}){3}:\d{1,5}");
            Regex proxyRegex2 = new Regex(@"\d{1,3}(\.\d{1,3}){3}</td><td>\d{1,5}");
            WebClient webClient = new WebClient();
            List<string> alreadyFound = new List<string>();
            string filename = "scraped_proxylist.txt";
            File.WriteAllText(filename, "");
            int counter = 0;
            foreach (string tofind in querys)
            {
                string url = "https://www.bing.com/search?q=" + tofind + "\"&count=#count#";
                try
                {
                    string code = webClient.DownloadString(url.Replace("#count#", count.ToString()));
                    MatchCollection matches1 = linkRegex.Matches(code);
                    foreach (Match match in matches1)
                    {
                        try
                        {
                            string s = match.Groups[1].Value;

                            if (s.StartsWith("http") & !s.Contains("amp") & !s.Contains("microsoft"))//amp & microsoft to avoid shit from Bing
                            {
                                string html = webClient.DownloadString(s);
                                MatchCollection matches = proxyRegex.Matches(html);
                                foreach (Match m in matches)
                                {
                                    string proxy = m.Groups[0].Value;
                                    if (!alreadyFound.Contains(proxy))
                                    {
                                        counter++;
                                        alreadyFound.Add(proxy);
                                        listBox1.Items.Add(proxy);
                                        File.AppendAllText(filename, proxy + Environment.NewLine);
                                    }
                                }
                                matches = proxyRegex2.Matches(html);
                                foreach (Match m in matches)
                                {
                                    string proxy = m.Groups[0].Value.Replace("</td><td>", ":");
                                    if (!alreadyFound.Contains(proxy))
                                    {
                                        counter++;
                                        alreadyFound.Add(proxy);
                                        listBox1.Items.Add(proxy);
                                        File.AppendAllText(filename, proxy + Environment.NewLine);
                                    }
                                }
                                label1.Text = "ProxyScraper " + "\"" + tofind + "\" Proxys = " + counter + " Url: " + s;
                            }
                        }
                        catch { }
                    }
                }
                catch { }
            }
            listBox1.Items.Add("Done!");
            label1.Text = "Proxyscraper" + counter + " proxies found.";
            while (true) { }
        }
    }
}


Zal iemand me verder op weg kunnen helpen?

Alvast bedankt :)
lees je post nog eens na, en corrigeer waar nodig want ik kan er nu geen vis van pellen. Of chocola van maken.

Acties:
  • 0 Henk 'm!

  • RobIII
  • Registratie: December 2001
  • Niet online

RobIII

Admin Devschuur®

^ Romeinse Ⅲ ja!

(overleden)
Sorry, maar zo werkt 't hier niet. Neem even onze Quickstart door en open dan een nieuw topic met enkel relevante(!) code a.u.b.

Oh, en als je [code=c#] gebruikt i.p.v. [code] krijg je extra-gratis syntax-highlighting erbij ;)

[ Voor 20% gewijzigd door RobIII op 16-08-2019 17:11 ]

There are only two hard problems in distributed systems: 2. Exactly-once delivery 1. Guaranteed order of messages 2. Exactly-once delivery.

Je eigen tweaker.me redirect

Over mij


Dit topic is gesloten.