def __init__(self, ports, host='localhost', **kw): pools = len(ports) PoolManager.__init__(self, max(10, pools), **kw) self._lock = threading.RLock() self.host = host if pools > 1: self.ports = np.array(ports, dtype=np.uint16) self._port = self._roll else: self.ports = ports[0] self._port = lambda: self.ports
def __init__(self, host='www.baidu.com', refer='https://www.baidu.com/', **kw): PoolManager.__init__(self, **kw) self.headers = { 'User-Agent': define_user_agent(), 'X-Forward-For': define_x_forward(), 'Host': host, 'Referer': refer, 'Accept': HDR_ACCEPT, 'Accept-Encoding': HDR_ACCEPT_ENCODING, 'Accept-Language': HDR_ACCEPT_LANG, 'Cache-Control': HDR_CACHE_CONTROL, 'Connection': HDR_CONN, 'If-Modified-Since': HDR_LAST_MOD }