2020-03-16 17:18:06 +01:00
import argparse
2020-06-26 18:11:22 +02:00
import json
from . api import Lookyloo
2020-03-16 17:18:06 +01:00
def main ( ) :
parser = argparse . ArgumentParser ( description = ' Enqueue a URL on Lookyloo. ' , epilog = ' The response is the permanent URL where you can see the result of the capture. ' )
parser . add_argument ( ' --url ' , type = str , help = ' URL of the instance (defaults to https://lookyloo.circl.lu/, the public instance). ' )
2020-06-26 18:11:22 +02:00
parser . add_argument ( ' --query ' , help = ' URL to enqueue. ' )
2020-04-21 18:41:57 +02:00
parser . add_argument ( ' --listing ' , default = False , action = ' store_true ' , help = ' Should the report be publicly listed. ' )
2020-06-26 18:11:22 +02:00
parser . add_argument ( ' --redirects ' , help = ' Get redirects for a given capture. ' )
2020-03-16 17:18:06 +01:00
args = parser . parse_args ( )
if args . url :
lookyloo = Lookyloo ( args . url )
else :
lookyloo = Lookyloo ( )
2020-03-17 15:13:52 +01:00
if lookyloo . is_up :
2020-06-26 18:11:22 +02:00
if args . query :
url = lookyloo . enqueue ( args . query , listing = args . listing )
print ( url )
else :
response = lookyloo . get_redirects ( args . redirects )
print ( json . dumps ( response ) )
2020-03-16 17:18:06 +01:00
else :
print ( f ' Unable to reach { lookyloo . root_url } . Is the server up? ' )