Benjamin Peterson | 90f5ba5 | 2010-03-11 22:53:45 +0000 | [diff] [blame^] | 1 | #! /usr/bin/env python3 |
Guido van Rossum | d3d8a1d | 2001-12-04 15:23:47 +0000 | [diff] [blame] | 2 | |
| 3 | import sys, webbrowser |
| 4 | |
| 5 | def main(): |
| 6 | args = sys.argv[1:] |
| 7 | if not args: |
Collin Winter | 6afaeb7 | 2007-08-03 17:06:41 +0000 | [diff] [blame] | 8 | print("Usage: %s querystring" % sys.argv[0]) |
Guido van Rossum | d3d8a1d | 2001-12-04 15:23:47 +0000 | [diff] [blame] | 9 | return |
| 10 | list = [] |
| 11 | for arg in args: |
| 12 | if '+' in arg: |
| 13 | arg = arg.replace('+', '%2B') |
| 14 | if ' ' in arg: |
| 15 | arg = '"%s"' % arg |
| 16 | arg = arg.replace(' ', '+') |
| 17 | list.append(arg) |
| 18 | s = '+'.join(list) |
Guido van Rossum | 65f5015 | 2002-02-08 16:20:07 +0000 | [diff] [blame] | 19 | url = "http://www.google.com/search?q=%s" % s |
Guido van Rossum | d3d8a1d | 2001-12-04 15:23:47 +0000 | [diff] [blame] | 20 | webbrowser.open(url) |
| 21 | |
Andrew M. Kuchling | e236b38 | 2004-08-09 17:27:55 +0000 | [diff] [blame] | 22 | if __name__ == '__main__': |
| 23 | main() |