def __init__(self, cert_path, key_path, insecure=False, proxy_configuration=None): HttpClient.__init__(self, cert_path, key_path, insecure, proxy_configuration)
class SpeedTester(threading.Thread): def __init__(self, queue, proxies): threading.Thread.__init__(self) self.daemon=True self.client=HttpClient() self.queue=queue self.proxies=proxies def test_speed(self, proxy): self.client.__init__(proxy) html=self.client.get('http://www.baidu.com', 'gbk') self.client.__init__() if html is None: return -1 else: return self.client.speed def run(self): while True: proxy=self.queue.get() speed=self.test_speed(proxy) if speed>0 and speed<3: print(proxy, speed, self.queue.qsize()) with lock: self.proxies.append((proxy, speed)) self.queue.task_done()
def __init__(self, cert_path, key_path, insecure=False): HttpClient.__init__(self, cert_path, key_path, insecure)