As an SEO metric I'd like to programmatically get the number of by Google indexed pages.
(if I search "site:mydomain.com" I want the get number of pages found).
Is there any lib for this or do I need to parse a google request?
As an SEO metric I'd like to programmatically get the number of by Google indexed pages.
(if I search "site:mydomain.com" I want the get number of pages found).
Is there any lib for this or do I need to parse a google request?
There's probably a Google API you can use, rather than parsing the results of a search.
Here's something I put together that will work for a few queries per IP address per hour:
public static Int32 GooglePages(string sourceDomain)
{
String googleSource
= (new WebClient()).DownloadString(
@"http://www.google.com/search?q=site%3A" + sourceDomain);
return Convert.ToInt32(
Regex.Match(googleSource,
@"about \<b\>([0-9,]*)\<\/b\> from ")
.Groups[1].Value.Replace(",", ""));
}
If you are going to use it often, or make many queries on a regular basis I would recommend using an officially sanctioned API.
Has your site been setup in Google Analytics? If so you can use the Google Analytics API to get such information.
If you're interested in how to implement this in asp.net refer to this question.
you should use Google Webmaster Tool API.
First login in google webmaster with gmail account and familiar with the functionality then see following developer guide:
http://code.google.com/apis/webmastertools/docs/2.0/developers%5Fguide.html