-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
executable file
·50 lines (43 loc) · 1.46 KB
/
main.py
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
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python3
import argparse
import sys
from src.crawl import run as run_crawl
from src.read import run as run_read
from src.utils import check_max_depth, check_url
operations = [
"crawl mail addresses from a given url or domain",
"output the mail addresses and the pages on which they were found",
]
def arguments():
parser = argparse.ArgumentParser(
prog="Email Spider",
description="A simple email spider that crawls a given url or domain for email addresses.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument("-d", "--domain", type=check_url, help="domain or url to crawl")
parser.add_argument(
"-m",
"--maxdepth",
type=check_max_depth,
default=2,
help="maximum depth to crawl (default: 2)",
)
parser.add_argument(
"-v", "--verbose", action="store_true", help="increase verbosity"
)
parser.add_argument(
"-vd", "--verifydomains", action="store_true", help="verify mail addresses when reading from database"
)
parser.add_argument("op", choices=["crawl", "read"], help="Operation to perform")
args = parser.parse_args()
return vars(args)
if __name__ == "__main__":
config = arguments()
match config["op"]:
case "crawl":
run_crawl(config)
case "read":
run_read(config)
case _:
print("Invalid operation. Exiting.")
sys.exit(1)