0

I need somebody who tell me how to use Html Agility Pack in Windows Forms. I have
`private void btnOnet_Click(object sender, EventArgs e)

    {
        HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
        HtmlWeb web = new HtmlWeb();
        doc = web.Load("https://pogoda.onet.pl/");
        var temperatura = doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'temperature')]/div[contains(@class, 'temp')]");
        onet.Text = temperatura.InnerHtml;
    }    `   

I don't know how to display result in textBox aftek click Button. Should I create another method or do all in private void btnOnet_Click

  • `web.Load()` will quite probably load the HTML source before it's rendered. So, also most probably, the element you're looking for has not been created yet, so `temperatura` is going to be null (something you can test yourself, debugging your code) -- Not an `int`, it would be a string, since it comes from a text source. – Jimi Apr 22 '22 at 13:49
  • Does this answer your question? [Scrape data from div in Windows.Form](https://stackoverflow.com/questions/71967403/scrape-data-from-div-in-windows-form) – Victor Apr 22 '22 at 13:55

0 Answers0