This repository was archived by the owner on Feb 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathmain.py
More file actions
38 lines (29 loc) · 1.3 KB
/
main.py
File metadata and controls
38 lines (29 loc) · 1.3 KB
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
29
30
31
32
33
34
35
36
37
38
from argparse import ArgumentParser
from dotenv import load_dotenv
from webspot.cmd.crawl import cmd_crawl
from webspot.cmd.request import cmd_request
from webspot.cmd.web import cmd_web
from webspot.constants.html_request_method import HTML_REQUEST_METHOD_REQUEST
load_dotenv()
parser = ArgumentParser()
subparsers = parser.add_subparsers(
title='subcommands',
description='valid subcommands',
help='additional help',
)
crawl_parser = subparsers.add_parser('crawl')
crawl_parser.add_argument('--url', '-U', help='url to crawl')
crawl_parser.add_argument('--output', '-o', help='output file path')
crawl_parser.set_defaults(func=cmd_crawl)
web_parser = subparsers.add_parser('web')
web_parser.add_argument('--host', '-H', default='0.0.0.0', help='port')
web_parser.add_argument('--port', '-P', default=80, type=int, help='port')
web_parser.add_argument('--log-level', '-L', default='debug', help='log level')
web_parser.set_defaults(func=cmd_web)
request_parser = subparsers.add_parser('request')
request_parser.add_argument('--url', '-U', help='url to request', required=True)
request_parser.add_argument('--method', '-M', help='request method', default=HTML_REQUEST_METHOD_REQUEST)
request_parser.set_defaults(func=cmd_request)
if __name__ == '__main__':
args = parser.parse_args()
args.func(args)