mbdAli
mbdAli

Reputation: 31

How to extract data from webpage?

I want to get text and data from a webpage. when a page load completes inside web-browser control, I just want to extract text from the page by element id? please help me how can i achieve this like html-agility & c#. Sorry for my poor english.

Upvotes: 0

Views: 555

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

You could use the GetElementbyId method on the HtmlDocument which allows you to retrieve some specific DOM element by its identifier:

string html = ... Read the HTML here

var htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.OptionFixNestedTags = true;
htmlDoc.LoadHtml(html);

var element = htmlDoc.GetElementbyId("someId");
if (element != null)
{
    string data = element.InnerText;
}

Upvotes: 2

Related Questions