forked from Largefreedom/python_zeroing-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshecdule.py
67 lines (52 loc) · 1.4 KB
/
shecdule.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
from multiprocessing import Process
from proxy_pool.flask_api import app
from proxy_pool.texter import Tester
from proxy_pool.proxy_getter import Getter
import time
API_HOST = '127.0.0.1'
API_PORT =5000
TSTER_CYCLE = 20
GETTER_CYCLE =20
TESTER_ENABLED = True
GETTER_ENABLED =True
API_ENABLED =True
class Sheduler():
def schedule_tester(self):
'''
定时测试代理
:param cycle:
:return:
'''
tester =Tester()
print('开始测试代理')
tester.run()
def schedule_getter(self):
'''
定时获取代理;
:param cycle:
:return:
'''
getter = Getter()
print('开始抓代理!!!!')
getter.run()
def shedule_api(self):
'''
开启代理:
:return:
'''
app.run(API_HOST,API_PORT)
def run(self):
print('代理池正在运行')
while True:
if TESTER_ENABLED:
tester_process = Process(target = self.schedule_tester())
tester_process.start()
print('抓取器开始运行:-----------')
if GETTER_ENABLED:
getter_process = Process(target=self.schedule_getter())
getter_process.start()
time.sleep(10)
print('打开api_________________________')
if __name__ =='__main__':
a =Sheduler()
a.run()