How to access Google Search “I'm Feeling Lucky” functionality using API?

放肆的年华 提交于 2020-03-21 20:37:51

问题


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?


回答1:


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:

http://www.google.com/search?q=my+keywords+for+search&btnI



回答2:


Deprecated You could use the Google API which is probably the best way to do it but will require more work api docs here https://developers.google.com/web-search/docs/

No longer working or you can go to this url with your seach query: http://www.google.com/webhp#q=your+search+query+here&btnI

be sure you add &btnI to the end otherwise it wont redirect


Update 2014

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:

https://www.google.com/search?q=your+search+query+here&btnI=

with of course your+search+query+here replaced with a URL encoded string.



来源:https://stackoverflow.com/questions/16877882/how-to-access-google-search-im-feeling-lucky-functionality-using-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!