(self)
| 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 | |
| 86 | if __name__ == '__main__': |
nothing calls this directly
no test coverage detected