40

I have 3 or 4 keywords I want to send from my PHP page to Google and return one page as if I had gone on to Google's site and searched using "I'm feeling lucky."

Does anyone know how to supply the keywords to Google?

What is the format?

e.g.:

www.google.co.uk/lucky?keywords="the royal family"
3

6 Answers 6

53

http://www.google.com/search?q=stackoverflow&btnI

Replace "stackoverflow" with your keywords.

4
  • Stripped to the bare minimum :) Commented Feb 26, 2010 at 15:37
  • I saw that "I am lucky button" has name=btnI, I wonder how did you know that it should be written to web site adress by appending to the end?
    – stckvrflw
    Commented Feb 26, 2010 at 15:47
  • 3
    Actually I inpected with Fiddler to see what URL was being requested upon clicking the "Feeling Lucky" button. Then I stripped all the obvious redundant parameters like language, source, etc from the URL, until I couldn't strip anymore. Commented Feb 26, 2010 at 15:52
  • 1
    Nice. That is the perfect answer!
    – marcusw
    Commented Feb 26, 2010 at 16:38
15

Like this:

http://www.google.com/search?hl=en&q={searchTerms}&btnI=I

I stands for Instant.

3
  • 2
    Why doesn't the I stand for "I'm feeling lucky?" Commented Feb 26, 2010 at 15:40
  • 1
    it does (it is the name of the button) put the browser removed everything after the '
    – Hogan
    Commented Feb 26, 2010 at 16:17
  • The name btnI comes from Google.
    – SLaks
    Commented Feb 26, 2010 at 16:23
6

The URL you'd need is:

https://www.google.com/search?q=SEARCHTERM&btnI=I'm+Feeling+Lucky

where "SEARCHTERM" is the keyword you search for.

3

Try this:

http://www.google.co.uk/search?q=the+royal+family&btnI=I

Replace "the+royal+family" with your url encoded search term.

1
  • It's been a while but in case it helps other users... If you want to use this in Firefox keyword.URL setting for instance, you have to let the &q parameter at the end of the url, this way : http://www.google.com/search?btnI=I&q= Commented Mar 5, 2013 at 20:37
2

You can also put the query at the end:

http://www.google.com/search?btnI&q=stackexchange

1
1

Try the following syntaxes:

1. http://www.google.com/search?q=stackoverflow&btnI

But sometimes it's not predictable and it's giving you search results instead.

2. http://www.google.com/webhp?#q=stackexchange+feeling+lucky&btnI

But sometimes you'll see some source code appearing in the second example, but you can ignore it.


btnI parameter is for Google Instant Enabled and btn is for Google Instant Disabled.