How to get data from a table on a website?

Asked

Viewed 59 times

3

I’m developing a program that captures the proxies and ports of this site, for the program to get the proxies I used regular expression and htmlagilitypack... However, how to get the doors? Since by expressions I would end up picking numbers that are not proxies?

var search = webBrowser1.Document.GetElementsByTagName("table");
        foreach (HtmlElement ele in search)
        {
            HtmlElement h2 = ele.Parent.FirstChild;
            if (h2.InnerText == "IP Address")
            {
                DataTable table = new DataTable();
                table.Columns.Add("IP");
                table.Columns.Add("Porta");

                HtmlElement tableBody = ele.FirstChild;
                foreach (HtmlElement tableRow in tableBody.Children)
                {

                    HtmlElement _IP = tableRow.FirstChild;

                    HtmlElement _Porta = _IP.NextSibling.NextSibling;

                    DataRow row = table.NewRow();

                    row[0] = _IP.InnerText;

                    row[1] = _Porta.InnerText;

                    table.Rows.Add(row);
                }
                dataGridView1.DataSource = table;
            }
        }
  • Hello @Alanassis, welcome to Sopt. Enjoy doing the Tour to better understand how the site works. As to your question, you can post the code you already have?

  • Ready @Joãomartins

  • What results do you get with this code? You can give some examples?

  • No haha, when the code arrives at "Htmlelement tableBody = it.Firstchild" It arrives at the wrong value, trying to tidy up...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.