url-abuse/client/bin/urlabuse

29 lines
740 B
Python
Executable File

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import argparse
from pyurlabuse import PyURLAbuse
import json
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Run a query against URL Abuse')
parser.add_argument('--url', type=str, help='URL of the instance.')
parser.add_argument('--query', help='URL to lookup')
parser.add_argument('--digest', action='store_true', help='Return the digest')
args = parser.parse_args()
if args.url:
urlabuse = PyURLAbuse(args.url)
else:
urlabuse = PyURLAbuse()
response = urlabuse.run_query(args.query, args.digest)
if args.digest:
print(response['digest'][0])
else:
print(json.dumps(response, indent=2))