Get the text of an element knowing its class

1

This is what I find on the web:

<span class="class1">30</span>

How can I get 30 if I already know the value class1 automatically ? (without having to wait for him to load to give him the order)

It works once and for some reason it does not work again. Until I change class and it works again only once. This is my code:

    private void Form1_Load(object sender, EventArgs e)
    {
        Brow.Navigate("website.com");
        Brow.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Dothing);
    }

    private void Dothing (object sender, WebBrowserDocumentCompletedEventArgs e)
    {        
        foreach (HtmlElement element in Brow.Document.GetElementsByTagName("span"))
        {
            if (element.GetAttribute("class")/*I tried "classname" too*/.Equals("class1"))
            {
                MessageBox.Show(element.innerHTML);
            }
        }
    }
    
asked by Xerenger 02.04.2018 в 10:35
source

0 answers