def cli():
    """
    Commandline for looter :d
    """
    argv = docopt(__doc__, version=VERSION)
    if argv['genspider']:
        name = f"{argv['<name>']}.py"
        use_async = argv['--async']
        template = 'data_async.tmpl' if use_async else 'data.tmpl'
        package_dir = Path(__file__).parent
        template_text = package_dir.joinpath('templates', template).read_text()
        Path(name).write_text(template_text)
    if argv['shell']:
        url = argv['<url>'] if argv['<url>'] else input(
            'Plz specific a site to crawl\nurl: ')
        res = requests.get(url, headers=DEFAULT_HEADERS)
        if not res:
            exit('Failed to fetch the page.')
        tree = Selector(text=res.text)
        allvars = {**locals(), **globals()}
        try:
            from ptpython.repl import embed
            print(BANNER)
            embed(allvars)
        except ImportError:
            code.interact(local=allvars, banner=BANNER)
def cli ( ) : argv = docopt ( __doc__ , version = VERSION ) if argv [ 'genspider' ] : name = f"{argv['<name>']}.py" use_async = argv [ '--async' ] template = 'data_async.tmpl' if use_async else 'data.tmpl' package_dir = Path ( __file__ ) . parent template_text = package_dir . joinpath ( 'templates' , template ) . read_text ( ) Path ( name ) . write_text ( template_text ) if argv [ 'shell' ] : url = argv [ '<url>' ] if argv [ '<url>' ] else input ( 'Plz specific a site to crawl\nurl: ' ) res = requests . get ( url , headers = DEFAULT_HEADERS ) if not res : exit ( 'Failed to fetch the page.' ) tree = Selector ( text = res . text ) allvars = { ** locals ( ) , ** globals ( ) } try : from ptpython . repl import embed print ( BANNER ) embed ( allvars ) except ImportError : code . interact ( local = allvars , banner = BANNER )
Commandline for looter :d