Avatar of pomorin
pomorin
 asked on

How to get only Meta tags from URL ?

Hello !

I use HttpWebRequest to get HTML from URL. Then I get Meta tags from HTML.
Can I get only Meta tags from URL ?

Thanks
.NET ProgrammingASP.NETC#

Avatar of undefined
Last Comment
Gary Davis

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gary Davis

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
pomorin

ASKER
Thank you for the reply.
I do it now(receiving the entire Html from which I parse and extract the <META> tags).
May be is there the method to get only meta tags from URL ?
pomorin

ASKER
Thank you for the reply.
I do it now(receiving the entire Html from which I parse and extract the <META> tags).
May be is there the method to get only meta tags from URL ?
Gary Davis

If the HTML is a valid XML document, you could load it into an XmlDocument from the string and use an xpath query to easily locate the META tags. However, most HTML is full of bugs, mismatched tags, etc (due to forgiving browsers) so the way you are doing it is probably sufficient (scanning the response string for the META tags).

Gary.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck