Get Number of Pages Indexed by Google with Vbscript
Have you ever needed to track the number of pages indexed daily for a site within Google? To save you some time, the following vbscript will grab the number of estimated pages Google returns as a single integer, the same as if you entered: site:crribs.com into the ‘Search’ box. The returned page gives you back – for example – Results 1 – 10 of about 171 from crribs.com. (0.19 seconds) . This script would return the number 171, for analytical/statistical tracking purposes. Make sure to enter the correct cannonical version of your site for the variable if youve specified one in Google Webmaster Tools.
varSite = "crribs.com"
WScript.Echo getGoogIndexedPages(varSite)
Function getGoogIndexedPages(strUrl)
strUrl = "http://www.google.com/search?hl=en&source=hp&q=site:" & strUrl & "&aq=f&aqi=&aql=&oq=&gs_rfai="
Set xmlhttp = createobject("msxml2.xmlhttp.3.0")
xmlhttp.open "get", strUrl, false
xmlhttp.send
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Global = True
objRegEx.Pattern = "of about \[\d|\,]*\<\/b\>" (Google updated the format of this page. Replace the RegEx and itll work again.)
objRegEx.Pattern = "About.\d+.\d+"
strSearchString = xmlhttp.responseText
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.count > 0 Then
For Each match In colMatches
strMatch = match
Next
End If
strMatch = Replace(strMatch, "of about ", "")
strMatch = Replace(strMatch, "", "")
getGoogIndexedPages = strMatch
End Function
Leave a Reply
You must be logged in to post a comment.