ยปCore Development>Code coverage>Tools/scripts/google.py

Python code coverage for Tools/scripts/google.py

#countcontent
1n/a#! /usr/bin/env python3
2n/a
3n/a"""Script to search with Google
4n/a
5n/aUsage:
6n/a python3 google.py [search terms]
7n/a"""
8n/a
9n/aimport sys
10n/aimport urllib.parse
11n/aimport webbrowser
12n/a
13n/a
14n/adef main(args):
15n/a def quote(arg):
16n/a if ' ' in arg:
17n/a arg = '"%s"' % arg
18n/a return urllib.parse.quote_plus(arg)
19n/a
20n/a qstring = '+'.join(quote(arg) for arg in args)
21n/a url = urllib.parse.urljoin('https://www.google.com/search', '?q=' + qstring)
22n/a webbrowser.open(url)
23n/a
24n/aif __name__ == '__main__':
25n/a main(sys.argv[1:])