Created
December 23, 2019 19:58
-
-
Save classmember/f31e215d0c08cb927e824b2d9fbec911 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from argparse import ArgumentParser | |
try: | |
from googlesearch import search | |
except ImportError: | |
print("No module named 'google' found") | |
def cli_args_string(parser = ArgumentParser()): | |
'''Returns space seperated string of all command line arguments | |
Args: | |
parser(ArgumentParser): parser for cli arguments | |
Returns: | |
string: all command line arguments | |
''' | |
parser.add_argument('query', nargs='*', help='search string') | |
return ' '.join(parser.parse_args().query) | |
def main(): | |
query = cli_args_string() | |
for link in search(query, tld="com", num=10, stop=10, pause=1): | |
print(link) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment