def __init__(self, queue, thread_name, origin_ips): ProxyManager.__init__(self) Thread.__init__(self, name=thread_name) self.queue = queue self.origin_ips = origin_ips self.log = LogHandler('useful_proxy_check')
def doUsefulProxyCheck(): proxy_queue = Queue() pm = ProxyManager() pm.db.changeTable(pm.useful_proxy_queue) for _proxy in pm.db.getAll(): proxy_queue.put(_proxy) thread_list = list() for index in range(10): thread_list.append(UsefulProxyCheck(proxy_queue, "thread_%s" % index)) for thread in thread_list: thread.start() for thread in thread_list: thread.join()
def doRawProxyCheck(): proxy_queue = Queue() pm = ProxyManager() pm.db.changeTable(pm.raw_proxy_queue) for _proxy in pm.db.getAll(): proxy_queue.put(_proxy) pm.db.clear() thread_list = list() for index in range(50): thread_list.append(RawProxyCheck(proxy_queue, "thread_%s" % index)) for thread in thread_list: thread.start() for thread in thread_list: thread.join()
def __init__(self): ProxyManager.__init__(self) self.log = LogHandler('fetch_proxy')
def __init__(self, queue, thread_name): ProxyManager.__init__(self) Thread.__init__(self, name=thread_name) self.log = LogHandler('raw_proxy_check') self.queue = queue
def get_filename(): image_url = request.form.get('image_url') sess = requests.Session() file_name = sess.get(image_url).content result = ProxyManager.get_result(file_name) return jsonify({'identify_code':result}) if result and result != 'error' else 'didn`t get code'