-1

If I have a variable, lets say, favorite singer, I want to open the web browser and search for that singer. I was planning to use the following code to open Google, but how can I make the users input become the actual search itself?

webbrowser.open('www.google.com')
user2519572
  • 61
  • 1
  • 1
  • 7

1 Answers1

2

To pre-populate the searchbox, use:

import webbrowser
from urllib import urlencode

webbrowser.open('http://www.google.com/?' + urlencode({'q': 'the quick brown fox'}))
Jon Clements
  • 132,101
  • 31
  • 237
  • 267