Welcome, guest | Sign In | My Account | Store | Cart

PyGoogle searches google. The google search engine uses 'http://www.google.com/search?hl=en&q=' plus whatever you are searching and replaces the spaces with '+' signs.

Python, 12 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
#PyGoogle searches Google
#Just prompts user input, replaces spaces with +'s, and opens the new URL w/ #the webbrowser module
#Could possibly add other search engines. I attempted with Ask.com but I think
#the search engine requires a cookie
import webbrowser
while 1:
    s = raw_input('Search: ')
    url_goog = 'http://www.google.com/search?hl=en&q='
    url_add1 = ''
    s = '+'.join((s.split(' ')))
    print s
    webbrowser.open(url_goog+s)

Allows a quick interface for searching Google without opening the Google homepage. May also be good for opening other websites if you know regular expressions.