-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProxyFileReader.py
35 lines (27 loc) · 1.13 KB
/
ProxyFileReader.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
import threading
import time
import re
import os
from os import listdir
from os.path import isfile, join
from Proxy import Proxy
class ProxyFileReader(threading.Thread):
def __init__(self):
super(ProxyFileReader, self).__init__()
def run(self):
while True:
fileList = [f for f in listdir('ProxyFiles') if isfile(join('ProxyFiles', f)) and f != '.gitkeep']
for file in fileList:
print("New file ready for processing: " + file)
lines = [line.strip() for line in open(join('ProxyFiles', file))]
for line in lines:
if re.match('^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d{1,5}$', line) is not None:
proxyParts = line.split(":")
px = Proxy(proxyParts[0], int(proxyParts[1]))
px.updateProxy()
# print(line, flush=True)
else:
print("Odd line: " + line, flush=True)
print("File processed and deleted: " + file)
os.remove(join('ProxyFiles', file))
time.sleep(60)