-
Notifications
You must be signed in to change notification settings - Fork 1
/google
28 lines (19 loc) · 821 Bytes
/google
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env python
import argparse
import sys
from src.googler import Googler
def parse_args(args):
parser = argparse.ArgumentParser(description='Query result from the internet and returning it back')
parser.add_argument('--search_engine', type=str, default='google', help="The search engine to query")
parser.add_argument('--debug', action='store_true', help='Enable debugging mode and print errors')
parser.add_argument('query', type=str, help="Query string")
args = parser.parse_args(args)
return args
def main(args):
args = parse_args(args)
if args.debug:
print("\n--- Goolger in debug mode ---\n")
googler = Googler(search_engine=args.search_engine, debug_mode=args.debug)
googler.search(query=args.query)
if __name__ == '__main__':
main(sys.argv[1:])