-
Notifications
You must be signed in to change notification settings - Fork 7
/
test-scrape.py
72 lines (49 loc) · 1.29 KB
/
test-scrape.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from plugins.scrapers.da.daScrape import GetDA
from plugins.scrapers.px.pxScrape import GetPX
from plugins.scrapers.hf.hfScrape import GetHF
from plugins.scrapers.fa.faScrape import GetFA
import flags
import settings
import logSetup
import signal
import multiprocessing.managers
import sys
manager = multiprocessing.managers.SyncManager()
manager.start()
namespace = manager.Namespace()
def go():
namespace.run=True
if len(sys.argv) < 2:
print("Specify site to scrape ('da', 'fa', 'hf', 'px')")
return
site = sys.argv[1].lower()
if site not in settings.settings['artSites']:
print("Invalid site!")
print("Please specify a *valid* site to scrape ('da', 'fa', 'hf', 'px')")
return
if site == "px":
fetch = GetPX()
elif site == "da":
fetch = GetDA()
elif site == "fa":
fetch = GetFA()
elif site == "hf":
fetch = GetHF()
else:
raise ValueError("WAT?")
print("Site", site)
# fetch = GetDA()
fetch.go(ctrlNamespace=namespace)
# daGrabber.go([", "])
def signal_handler(dummy_signal, dummy_frame):
if flags.run:
flags.run = False
namespace.run=False
print("Telling threads to stop")
else:
print("Multiple keyboard interrupts. Raising")
raise KeyboardInterrupt
if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler)
logSetup.initLogging()
go()