當前位置: 首頁>>代碼示例>>Python>>正文


Python socks.SOCKSProxyManager方法代碼示例

本文整理匯總了Python中urllib3.contrib.socks.SOCKSProxyManager方法的典型用法代碼示例。如果您正苦於以下問題:Python socks.SOCKSProxyManager方法的具體用法?Python socks.SOCKSProxyManager怎麽用?Python socks.SOCKSProxyManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在urllib3.contrib.socks的用法示例。


在下文中一共展示了socks.SOCKSProxyManager方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GetExternalIP

# 需要導入模塊: from urllib3.contrib import socks [as 別名]
# 或者: from urllib3.contrib.socks import SOCKSProxyManager [as 別名]
def GetExternalIP(self, proxy=None): 
        timeout = self.timeout.get()
        
        file = "Data/tordata%s/ip.txt" % (proxy-9050)
        url = 'http://checkip.amazonaws.com'
        interval = int(self.time.get()-1)
        soc = SOCKSProxyManager('socks5://127.0.0.1:%s/' % proxy)
        s = soc.request('GET', url, timeout=urllib3.Timeout(connect=interval, read=interval), retries=False)
        d = s.data.decode('utf-8').split('\n')
        f = open(file, 'w')
        f.write(d[0])
        f.close()
        s.close()
        
        
    #funkce na zjisteni odezvy pro zjistenou IP adresu, nejdrive zavola zjisteni IP a nasledne provede overeni odezvy, a vypise vystup do aplikace 
開發者ID:seevik2580,項目名稱:tor-ip-changer,代碼行數:18,代碼來源:start.py

示例2: pageRequest

# 需要導入模塊: from urllib3.contrib import socks [as 別名]
# 或者: from urllib3.contrib.socks import SOCKSProxyManager [as 別名]
def pageRequest(url):
    global roundRobin
    proxy = SOCKSProxyManager('socks5://localhost:'+str(torPort),
        cert_reqs='CERT_REQUIRED',
        ca_certs=certifi.where(),
        headers={'user-agent': randomUserAgent(), 'Cookie': ''})
    http = urllib3.PoolManager( 1,
        cert_reqs='CERT_REQUIRED',
        ca_certs=certifi.where(),
        headers={'user-agent': randomUserAgent(), 'Cookie': ''})
    if roundRobin % 2:
        response = http.request('GET', url)
    else:
        if torSupport:
            response = proxy.request('GET', url)
        else:
            response = http.request('GET', url)
    roundRobin += 1
    if not roundRobin % 60:
        newTorIdentity()
    return response.data 
開發者ID:pielco11,項目名稱:JungleScam,代碼行數:23,代碼來源:junglescam.py

示例3: __init__

# 需要導入模塊: from urllib3.contrib import socks [as 別名]
# 或者: from urllib3.contrib.socks import SOCKSProxyManager [as 別名]
def __init__(self, url, user_agent, cookies_string=False, custom_header=False, insecure_ssl='false', proxy=False):
        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        self.__url = url
        self.__headers = dict()
        self.__headers['User-Agent'] = self.__default_user_agent if user_agent == 'default' else user_agent
        if cookies_string:
            self.__headers['Cookie'] = cookies_string
        if custom_header:
            self.__parse_custom_header(custom_header)
        self.__verify = 'CERT_REQUIRED' if insecure_ssl == 'false' else 'CERT_NONE'
        if proxy:
            proxy_type = proxy.split('://')[0]
            if proxy_type == 'http' or proxy_type == 'https':
                self.__request_obj = urllib3.ProxyManager(proxy, ssl_version=ssl.PROTOCOL_TLSv1,
                                                          timeout=self.__request_timeout, cert_reqs=self.__verify)
            else:
                self.__request_obj = SOCKSProxyManager(proxy, ssl_version=ssl.PROTOCOL_TLSv1,
                                                       timeout=self.__request_timeout, cert_reqs=self.__verify)
        else:
            self.__request_obj = urllib3.PoolManager(ssl_version=ssl.PROTOCOL_TLSv1, timeout=self.__request_timeout,
                                                     cert_reqs=self.__verify)
        # print (vars(self)) 
開發者ID:antonioCoco,項目名稱:SharPyShell,代碼行數:24,代碼來源:Request.py

示例4: SOCKSProxyManager

# 需要導入模塊: from urllib3.contrib import socks [as 別名]
# 或者: from urllib3.contrib.socks import SOCKSProxyManager [as 別名]
def SOCKSProxyManager(*args, **kwargs):
        raise InvalidSchema("Missing dependencies for SOCKS support.") 
開發者ID:danielecook,項目名稱:gist-alfred,代碼行數:4,代碼來源:adapters.py

示例5: proxy_manager_for

# 需要導入模塊: from urllib3.contrib import socks [as 別名]
# 或者: from urllib3.contrib.socks import SOCKSProxyManager [as 別名]
def proxy_manager_for(self, proxy, **proxy_kwargs):
        """Return urllib3 ProxyManager for the given proxy.

        This method should not be called from user code, and is only
        exposed for use when subclassing the
        :class:`HTTPAdapter <requests.adapters.HTTPAdapter>`.

        :param proxy: The proxy to return a urllib3 ProxyManager for.
        :param proxy_kwargs: Extra keyword arguments used to configure the Proxy Manager.
        :returns: ProxyManager
        :rtype: urllib3.ProxyManager
        """
        if proxy in self.proxy_manager:
            manager = self.proxy_manager[proxy]
        elif proxy.lower().startswith('socks'):
            username, password = get_auth_from_url(proxy)
            manager = self.proxy_manager[proxy] = SOCKSProxyManager(
                proxy,
                username=username,
                password=password,
                num_pools=self._pool_connections,
                maxsize=self._pool_maxsize,
                block=self._pool_block,
                **proxy_kwargs
            )
        else:
            proxy_headers = self.proxy_headers(proxy)
            manager = self.proxy_manager[proxy] = proxy_from_url(
                proxy,
                proxy_headers=proxy_headers,
                num_pools=self._pool_connections,
                maxsize=self._pool_maxsize,
                block=self._pool_block,
                **proxy_kwargs)

        return manager 
開發者ID:danielecook,項目名稱:gist-alfred,代碼行數:38,代碼來源:adapters.py

示例6: __init__

# 需要導入模塊: from urllib3.contrib import socks [as 別名]
# 或者: from urllib3.contrib.socks import SOCKSProxyManager [as 別名]
def __init__(self, handler, range_start, range_end):
        self.handler = handler
        self.write = handler.wfile.write
        self.url = handler.url
        self.scheme = handler.url_parts.scheme
        self.netloc = handler.url_parts.netloc
        self.headers = dict((k.title(), v) for k, v in handler.headers.items())
        self.headers['Host'] = self.netloc
        self.headers.update(fake_headers)

        self.range_start = range_start
        self.range_end = range_end
        self.delay_cache_size = self.max_size * self.threads * 4
        self.delay_star_size = self.delay_cache_size * 2
        self.max_threads = min(self.threads * 2, self.pool_size)

        if self.http is None:
            connection_pool_kw = {
                'block': True,
                'timeout': self.timeout,
                'maxsize': self.pool_size
            }
            if self.proxy:
                if self.proxy.lower().startswith('socks'):
                    from urllib3.contrib.socks import SOCKSProxyManager as ProxyManager
                else:
                    ProxyManager = urllib3.ProxyManager
                http = ProxyManager(self.proxy, **connection_pool_kw)
                if ProxyManager is not urllib3.ProxyManager:
                    http.connection_pool_kw['_socks_options']['rdns'] = True
            else:
                http = urllib3.PoolManager(**connection_pool_kw)
            self.__class__.http = http

        self.firstrange = range_start, range_start + self.first_size - 1

        self.data_queue = Queue.PriorityQueue()
        self.range_queue = Queue.LifoQueue()
        self._started_threads = {} 
開發者ID:ForgQi,項目名稱:bilibiliupload,代碼行數:41,代碼來源:rangefetch_server.py

示例7: get_tor_session

# 需要導入模塊: from urllib3.contrib import socks [as 別名]
# 或者: from urllib3.contrib.socks import SOCKSProxyManager [as 別名]
def get_tor_session(self):
        """
        Configures and create the session to use a Tor Socks proxy.

        :return: urllib3.SOCKSProxyManager object.
        """
        user_agent = {'user-agent':
                'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'}
        session = SOCKSProxyManager('socks5://{0}:{1}'.format(self.ip, self.socksport), cert_reqs='CERT_REQUIRED',
                                    ca_certs=certifi.where(), headers=user_agent)
        return session 
開發者ID:SekouD,項目名稱:mlconjug,代碼行數:13,代碼來源:utils.py


注:本文中的urllib3.contrib.socks.SOCKSProxyManager方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。