Reputation: 11498
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?
Upvotes: 1
Views: 2143
Reputation: 6122
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_guide.html
Upvotes: 5
Reputation: 2961
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.
Upvotes: 2
Reputation: 5981
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.
Upvotes: 3
Reputation: 21882
There's probably a Google API you can use, rather than parsing the results of a search.
Upvotes: 0