I'm creating a sample app that will take a query from user and will return the URL result returned from Google's "I'm Feeling Lucky" search. Does Google expose this functionality through their API? How to access this?Answer1:
There is nothing magic about Google's "I'm Feeling Lucky" functionality. It simply picks the first result of the search. So, however you're using the api, you can just select the first result as well.
Furthermore, you can use this format for a URL in order to hit the "I'm Feeling Lucky" result of Google:
<em>Deprecated</em> <strike>You could use the Google API which is probably the best way to do it but will require more work api docs here <a href="https://developers.google.com/web-search/docs/" rel="nofollow">https://developers.google.com/web-search/docs/</a></strike>
<em>No longer working</em> <strike>or you can go to this url with your seach query: <a href="http://www.google.com/webhp#q=your+search+query+here&btnI" rel="nofollow">http://www.google.com/webhp#q=your+search+query+here&btnI</a></strike>
be sure you add &btnI to the end otherwise it wont redirect<hr />
The above URL stopped working and yes the search API is depreciated, however there are always workaround. If you really have to you can still use a simple get request on the following URL:
<a href="https://www.google.com/search?q=your+search+query+here&btnI=" rel="nofollow">https://www.google.com/search?q=your+search+query+here&btnI=</a>
with of course
your+search+query+here replaced with a URL encoded string.