Skip to content

Reading Meta Tags from HTML

Juan Castillo

Asked Feb 15, 2009, 2:48 PM EST1 answer
Share
LinkedInX

Whats Up guys

I'm building a small app just for fun that can read Meta Tags.  I want open a page from a given URL (http://www.example.com) and be able to search for a particular Meta Tag (<meta http-equiv="refresh" content="1;url="index.htm">) The program should be able to find this tag and extra the URL.  I have been searching all day long without a single way on doing this. Can anyone give me hand?

Regards,

Juan

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Do you want to do it from a BHO or simple windows app ?
    In case you want to do it in winodws application use a webbrowser control and from it's document you can easily read Meta tags using the following code

    HtmlDocument doc = webBrowser1.Document;

    HtmlElementCollection metatags = doc.GetElementsByTagName("meta");

    foreach (HtmlElement el in metatags)
    {
    MessageBox.Show(""+el.OuterHtml);
    }

    Hope this helps.
    0