-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (23 loc) · 813 Bytes
/
main.py
File metadata and controls
31 lines (23 loc) · 813 Bytes
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
from __future__ import annotations
import argparse
from pathlib import Path
from crawler.engine import CrawlerEngine
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="Run a config-driven crawler task.")
parser.add_argument(
"--config",
required=True,
help="Path to a YAML crawler config, for example configs/example_static.yaml",
)
return parser.parse_args()
def main() -> None:
args = parse_args()
config_path = Path(args.config)
engine = CrawlerEngine.from_yaml(config_path)
result = engine.run()
print(
f"Task finished: fetched={result.fetched}, parsed={result.parsed}, "
f"saved={result.saved}, skipped={result.skipped}, failed={result.failed}"
)
if __name__ == "__main__":
main()