Well, I hate to say this, but we've got more problems than the  
automated query thing. Your application is doing what is called  
"screen scraping," or parsing Google's standard web interface for  
information. This is explicitly prohibited in the general terms of use  
for Google. Instead, you need to be using the AJAX Search API, which  
is documented at the links below:

http://code.google.com/apis/ajaxsearch/documentation/index.html#fonje
http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje

What you appear to be looking for, more specifically, is the  
estimatedResultCount property of the api's cursor property. This value  
will give you an *estimate* of the number of results Google found for  
your query. Please note, though, that this property does tend to be  
rather inaccurate and widely variable. So I really wouldn't depend on  
it for mission-critical stuff.

All of that said, you will still run into the same automated query  
limitation that you were afraid of before. The AJAX APIs TOS still  
prohibit the use of applications to submit entirely automated queries.  
Basically, searches must be triggered by direct user interaction. Now,  
you can run two or five or fifty searches as a result of that  
interaction, but you can't, for instance, set up a cron job to run  
even one query at a given date and/or time.

You will probably also want to consult the rest of the TOS, which is  
linked below:

http://code.google.com/apis/ajaxsearch/terms.html



Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
[email protected]

Unless otherwise noted, any price quotes contained within this  
communication are given in US dollars.

If you're in the Des Moines, IA, area, check out Debra Heights  
Wesleyan Church!

And check out my blog, Adventures in Web Development, at 
http://jgeerdes.blogspot.com 
  !


On Sep 24, 2009, at 1:08 PM, GRF wrote:

>
> I 've written an ASP .NET C# application using Visual Studio 2005 and
> need to perform search queries for various phrases but without any GUI
> elements. I've looked at many code examples but can't see how to do
> Raw searches and get the results in a variable so I check them in the
> result.
>
> This is what I'm trying to mimic which I beleive is considered an
> automated query which is a NO-NO!
>
> The code below basically sends a Google search request for a phrase,
> gets the reponse, looks for the ";swrnum" in the reponse and get the
> number of search pages(hit count) for the phrase. Then I take that
> number and use it within my application.
>
> Please, any help is appreciated.
>
> HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://
> www.google.com/search?q=\"MY SEARCH PHRASE
> \"&ie=UTF-8&oe=UTF-8&hl=nl&meta=");
>
>                // Set some reasonable limits on resources used by
> this request
>                request.MaximumAutomaticRedirections = 4;
>                request.MaximumResponseHeadersLength = 4;
>
>                // Set credentials to use for this request.
>                request.Credentials =
> CredentialCache.DefaultCredentials;
>                HttpWebResponse response = (HttpWebResponse)
> request.GetResponse();
>
>                // Get the stream associated with the response.
>                Stream receiveStream = response.GetResponseStream();
>
>                // Pipes the stream to a higher level stream reader
> with the required encoding format.
>                StreamReader readStream = new StreamReader
> (receiveStream, Encoding.UTF8);
>
>                string returnedValue = readStream.ReadToEnd();
>
>                Regex rx = new Regex(";swrnum");
>
>                // Find a single match in the string.
>                Match m = rx.Match(returnedValue);
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-ajax-search-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to