MCPcopy Create free account
hub / github.com/Python3WebSpider/ProxyPool / GetIpThread

Class GetIpThread

examples/usage2.py:60–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58
59
60class GetIpThread(threading.Thread):
61 def __init__(self, fetchSecond):
62 super(GetIpThread, self).__init__()
63 self.fetchSecond = fetchSecond
64
65 def run(self):
66 global ips
67 while True:
68 # 获取IP列表
69 res = requests.get(apiUrl).content.decode()
70 # 按照\n分割获取到的IP
71 ips = res.split('\n')
72 # 利用每一个IP
73 for proxyip in ips:
74 if proxyip.strip():
75 # 开启一个线程
76 # CrawlThread(proxyip).start()
77 try:
78 CrawlThread(proxyip).run()
79 time.sleep(1.5)
80 except Exception as e:
81 print(e)
82 # 休眠
83 time.sleep(len(ips) /self.fetchSecond )
84
85
86if __name__ == '__main__':

Callers 1

usage2.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected