Click here to Skip to main content
15,890,897 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to fetch meta information of any website using Website Domain name as a input

ex. input in textbox is "www.mywebsite.com"
then on clicking on button i want meta information

how can i get it
help....

advance thanks
Posted
Updated 5-May-12 20:35pm
v2
Comments
Sandeep Mewara 5-May-12 10:49am    
What do you mean by 'meta information' of a website?
PKriyshnA 5-May-12 11:11am    
i mean i want to fetch meta keywords used for seo...

Look here: C# Station: Fetching Web Pages with HTTP.
You can parse the resulted text as xml, but i suggest using regular expressions to extract what you need.
 
Share this answer
 
I assume the term metadata refers to the Headers information, if so then following code will help you to start,

C#
namespace ConsoleApplication24
{
    using System;
    using System.Net;
    class Program
    {
        static void Main(string[] args)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.Codeproject.com");
            request.Method = "GET";
            IWebProxy proxy = WebRequest.GetSystemWebProxy();
            proxy.Credentials = CredentialCache.DefaultCredentials;
            request.Proxy = proxy;

            using (WebResponse response = request.GetResponse())
            {
                WebHeaderCollection collection = response.Headers;

                Array.ForEach(collection.AllKeys,
                    key =>
                    {
                        Console.WriteLine("{0,20}:{1}", key, string.Concat(collection.GetValues(key)));
                    });
            }
        }
    }
}


This code will produce following output,


    Proxy-Connection:Keep-Alive
          Connection:Keep-Alive
      Content-Length:94210
       Cache-Control:private
        Content-Type:text/html; charset=utf-8
                Date:Sun, 06 May 2012 03:40:03 GMT
          Set-Cookie:SessionGUID=f20a2597-70c8-4a1a-97b9-718fc0c108d9; path=/mgu
id=39d8dd1e-4189-44d6-9738-9cb90c7dade9; domain=.codeproject.com; expires=Tue05-
May-2037 04:00:00 GMT; path=/SessionGUID=f20a2597-70c8-4a1a-97b9-718fc0c108d9; p
ath=/mguid=39d8dd1e-4189-44d6-9738-9cb90c7dade9; domain=.codeproject.com; expire
s=Tue05-May-2037 04:00:00 GMT; path=/
                 Age:2
Press any key to continue . . .


Or if we want to get meta tag please have a look,

C# Parse Meta Tags[^]

Hope it helps a bit :)
 
Share this answer
 
v2
Comments
PKriyshnA 6-May-12 0:03am    
here i want SEO keyword in a string

then i want to calculate length od this string....

then how can i show what keyword used by site....
i want to show keywords
string length
and give user some suggetion based on length...
Mohammad A Rahman 6-May-12 0:46am    
What do you mean by Keyword or SEO? Show some example or your code..
Zoltán Zörgő 6-May-12 0:37am    
Mohammed's solution is showing http header not the html header. The later one is in the http content. Have you triet what I suggested? Are you familiar with regular expressions?

Just to be sure: you want to extract what's in
<meta name="keywords" content="word1, word2" />
tag?
Mohammad A Rahman 6-May-12 0:48am    
Zoltán, yes you are right but the question wasn't clear....
PKriyshnA 6-May-12 1:33am    
it meta tag is,

<meta name="keywords" content="word1, word2, word 3" />

then i want output as a sring
Output=word1, word2, word 3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900