-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (27 loc) · 797 Bytes
/
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
import threading
from queue import Queue
from logger import logger, obj_processed
from scrapper import scrapper
from config import folders_path, WORKERS
def main():
global obj_processed
check = input("give url or filename: ")
if check.startswith("https"):
print(check)
with open(folders_path, "w") as fl:
fl.write(check)
lock = threading.Lock()
q = Queue()
obj_processed = 0
with open(folders_path) as fl:
for i in fl:
q.put([i.strip(), 0])
with open(folders_path, "w") as fl:
fl.write("")
for i in range(WORKERS):
thread = threading.Thread(
name=f"Thread_{i}", target=scrapper, args=(q, lock,))
thread.daemon = True
thread.start()
q.join()
main()