views:

40

answers:

1

I have a list of URLs and I need to display the Google search terms that were performed within them. The problem is that some of the Google search terms that come up are just requests from the Google search bar so that it can display its dropdown list of suggestions. I need to distinguish between these and I am not sure how to since I don't understand Google's abbreviated request parameters.

I thought I would ask to see if anybody knew how to tell them apart before I dug in and did it myself. Thanks!

Here's a couple of example searches.

From the search bar:

http://www.google.com/webhp?hl=en&tab=iw#hl=en&client=hp&q=leonardo&aq=f&aqi=g10&aql=&oq=leonardo&gs_rfai=&fp=8631cdd35a4d476d

A full search:

http://www.google.com/search?hl=en&client=hp&q=leonardo&aq=f&aqi=g10&aql=&oq=leonardo&gs_rfai=&fp=8631cdd35a4d476d&tch=1&ech=1&psi=1idgTO3ODI6CsQPm5aH0DQ12813700709361

A: 

I'm pretty sure that the original query in either of the examples you've provided is simply 'leonardo', present in the q parameter of the query string. So in effect, all search terms will follow the 'q=', with multiple words separated by plus (+) symbols.

Examples

Single word: q=leonardo

Multiple words: q=leonardo+da+vinci

Hope this helps

~DJ

DJ Quimby
Right! I know how to get the query (it is, as you said, the 'q' parameter). What I don't know is how to differentiate between a full search (which returns a search page) and a "quick" or "live" search which is performed asynchronously when the user is typing into the search bar. If you click the links in the post one takes you to a webpage and the other brings up some json or something. Thanks!
J. Frankenstein
I mistakenly put two "quick" searches in my post. I fixed it so that there is a difference between the two. Whoops!
J. Frankenstein
I see your dilemma now. That json thing is a bit strange. I know you were looking for someone who knew the answer already but since no one has answered any better all I can do is offer another idea: simply see which variables show up in one type of query and not the other, then determine the type based on those variables' presence or non-presence.
DJ Quimby
This may also help: http://www.wordcat.co.uk/articles/disentangling-the-google-search-query-string/80/
DJ Quimby