Your task is to create a program which, given an input string, will output the first Google autocomplete result for that search. The format of input/output is up to you.
Rules
- Your program must take 1 input, a string, and output the top Google autocomplete/auto-fill suggestions result. The format of input/output is up to you. Just be sure to mention what your I/O format is.
- Obviously, accessing the Internet is allowed.
- URL shorteners (like bit.ly, TinyURL, etc.) are strictly disallowed. You should fetch your autocomplete results from this URL: http://suggestqueries.google.com/complete/search?client=your_browser&q=your_query or http://google.com/complete/search?client=your_browser&q=your_query. You are allowed to assume any browser name (or string, for that matter) for
client
. In the program I wrote, I assume Chrome. Any browser name or string should work. You are allowed to pass any options to the webpage as long as you are using some variant of http://suggestqueries.google.com/complete/search. - Please provide an explanation of how your program works. It is not mandatory, but I strongly advise it.
- All standard loopholes are strictly forbidden.
Test Cases
These are constantly changing, so edit this post if these become out-of-date.
'how to'
=> 'how to make slime'
'code golf'
=> 'code golf languages'
'you'
=> 'youtube'
'g'
=> 'google' (why would you google 'google'?)
This is code-golf, so may the shortest code win and the best programmer prosper...
output=toolbar
, we don't have to specify a client at all. \$\endgroup\$https -> http
(save 1 byte), removewww.
(save 4 bytes),google.com -> google.us
(save 1 byte) or evengoogle.com -> g.cn
(save 6 bytes; i'm not sure why this still works, but it seems that it still working in 20170424) \$\endgroup\$