-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcrawlerserver.py
More file actions
50 lines (37 loc) · 1.03 KB
/
Copy pathcrawlerserver.py
File metadata and controls
50 lines (37 loc) · 1.03 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
39
40
41
42
43
44
45
46
47
48
49
50
"""
This script is not required, driver can be called directly from a project.
- we just show off how it can be done
- it can be used to compare with other crawling scripts
"""
import json
import time
import argparse
import sys
from src import webtools
def main():
webtools.WebConfig.use_print_logging()
parser = webtools.ScriptCrawlerParser()
parser.parse()
if not parser.is_valid():
sys.exit(1)
return
if not parser.args.output_file:
print("Please specify output directory")
sys.exit(1)
return
request = parser.get_request()
driver = webtools.ServerCrawler(
request,
response_file=parser.args.output_file,
response_port=parser.args.port,
script="poetry run python crawlerrequests.py",
)
if parser.args.verbose:
print("Running request:{} with ServerCrawler".format(request))
if not driver.run():
print("Cannot start driver")
sys.exit(1)
return
driver.save_response()
driver.close()
main()