The cake is a lie

Google’s Lucky is fickle, too

One of Google’s most used underacknowledged features is the I’m Feeling Lucky query. On the surface, it seems silly and beside the point, but many people have grown to depend on it. What is it good for? Link resolving. You could go to Youtube.com and type “Rickroll” into the search box, or you could type “rickroll video” into your Firefox address bar (effectively doing an I’m Feeling Lucky search) and jump straight to where you want to go.

I no longer type “wikipedia.org” when I can type “wikipedia“. Why type “mail.google.com” when I can just type “gmail“? To me, Google has become a kind of DNS — resolving keywords into a complete URL. At that point, it’s hardly even search — it’s just a convenient side effect.

Providing a transparent link resolving service seems like a great selfless gesture by our unevil Google overlords. Rescuing the lazy with transparency and anonymity… Well, not quite. It turns out that the I’m Feeling Lucky feature only really works if you run it from the Google homepage, and approximately half-works from anywhere else.

Getting technical…

Anyone can turn a normal Google query into an I’m Feeling Lucky query, just append btnI=1 to the end of the URL (contrary to popular belief, btnI can take on any value, even empty string).

Let’s examine the problem. Consider this query:
workerpool site:shazow.net

Try opening that link, and then to compare, try the same query from google.com by hitting I’m Feeling Lucky.

Notice how clicking the link brings you to the Google results page, but the same query from the Google homepage does what it’s supposed to — takes you to the first result. It’s starting to become evident what’s going on here, but let’s beat this dead horse into the ground by hand crafting some HTTP requests, for great justice.

$ nc google.com 80
GET /search?q=workerpool+site%3Ashazow.net&btnI=1 HTTP/1.1
User-Agent: Mozilla/5.0 (Oh hai, I can haz redirect?)
 
HTTP/1.1 200 OK
Cache-Control: private, max-age=0
Date: Thu, 09 Oct 2008 01:07:47 GMT
Expires: -1
Content-Type: text/html; charset=UTF-8
...
 
$ nc google.com 80
GET /search?q=workerpool+site%3Ashazow.net&btnI=1 HTTP/1.1
User-Agent: Mozilla/5.0 (Oh hai, I can haz redirect?)
Referer: http://www.google.com/webhp?hl=en
 
HTTP/1.1 302 Found
Location: http://shazow.net/blog/2008/04/02/gentoo-rockband-code-and-music/
...

I used netcat to send a raw socket request (the first two lines) to google.com on port 80, and then Google responded (lines 4 and onwards). There are two requests, one is a vanilla request and the second includes a fake Referer header claiming that I was coming from the Google homepage, which yielded the 302 redirect we want.

Sometimes external I’m Feeling Lucky links work, other times they don’t. It appears that Google has some secret threshold to decide when to get in the way of your destination like an angry ceiling cat catapulting itself onto your face. It seems to happen when there’s a small number of results, or the magic search juice score of the top score is relatively low.

Sadface, but what can we do?

Google may not be completely selfless, but they’re still pretty good compared to some jerkwads. Thankfully, Google provides a no-strings-attached search API to their wonderful magic search juice. It’s not very well advertised (or clearly documented), but once you hunt it down, it’s simpler than sketching a wrinkly gourd. Observe: Same fail query as above in JSON.

Writing your own I’m Feeling Lucky redirector is a piece of cake. I took the liberty of making one on the Google App Engine with a few bonus features:
http://302found.appspot.com/ (source code @ github)

3 Comments so far

  1. Igor October 16th, 2008 7:31 am

    Umm, actually clicking the link to the btnI=1 query gets me the first result instead of the results page. :P

  2. Igor October 16th, 2008 7:32 am

    Never mind, that only worked from google reader :)

  3. jester November 17th, 2008 4:43 pm

    typing in some fun phrases bring up some sweet results under the \’im feeling lucky\’

    try typing in \’google leet\’
    or \’find chuck norris\’
    then click the im feeling lucky tab.

Leave a reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a