-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
29 lines (25 loc) · 898 Bytes
/
Copy pathmain.py
File metadata and controls
29 lines (25 loc) · 898 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
import sys
from crawl import crawl_site_async
import asyncio
from json_report import write_json_report
async def main():
if len(sys.argv) < 2:
print("no website provided")
sys.exit(1)
elif len(sys.argv) > 4:
print("too many arguments provided")
sys.exit(1)
else:
BASE_URL = sys.argv[1]
MAX_CONCURRENCY = int(sys.argv[2])
MAX_PAGES = int(sys.argv[3])
print("starting crawl of:", BASE_URL)
page_data = await crawl_site_async(BASE_URL, MAX_CONCURRENCY, MAX_PAGES)
print(f"There are {len(page_data)} pages that have been scraped.")
write_json_report(page_data)
# for page in page_data.values():
# if page is None:
# continue
# print(f"- {page['url']}: {len(page['outgoing_links'])} outgoing links")
if __name__ == "__main__":
asyncio.run(main())