How do I get Google search request completion suggestions from console?
When one starts typing a search request on Google search page, Google shows a dropdown with some popular completion suggestions. There are often useful or funny things there.
How do I get that list without GUI?
Expecting something like:
$ curl https://www.google.com/.... "How do I" ... | ...
how do I love thee
how do I get a passport
how do I craft this again
how do I live without you
Using this URL still works for me:
http://suggestqueries.google.com/complete/search?client=firefox&q=how+do+i
You'll get a JSON-file back which you can parse to get the completion suggestions.
There are some options (like callback, etc) but for you this url would serve its purpose.
Result (i added the linebreaks myself so you'll need to parse this JSON):
["how do i",
["how do i craft this again",
"how do i live without you",
"how do i know if i have 32 or 64 bit windows 7",
"how do i live",
"how do i breathe lyrics",
"how do i look bald",
"how do i download youtube videos",
"how do i look with a beard",
"how do i know if i have 32 or 64 bit windows 8",
"how do i live leann rimes"
]
]
You can also create a small php-file
<?php
$url = sprintf("http://suggestqueries.google.com/complete/search?client=firefox&q=%s", urlencode("how do i"));
$json = file_get_contents($url);
$results = json_decode(utf8_encode($json));
print_r($results);
the result of php myfile
would be:
Array
(
[0] => how do i
[1] => Array
(
[0] => how do i love thee
[1] => how do i get a passport
[2] => how do i craft this again
[3] => how do i live without you
[4] => how do i renew my passport
[5] => how do i live lyrics
[6] => how do i put this gently
[7] => how do i print screen
[8] => how do i enable cookies
[9] => how do i take a screenshot
)
)
(I'm not sure why the results are different but it probably has something to do with the fact Google can detect what client/useragent you're using and gives results accordingly)