Python set proxy
60 Python code examples are found related to "
set proxy".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: systemconfig.py From macops with Apache License 2.0 | 6 votes |
def SetProxy(self, enable=True, pac=CORP_PROXY): """Set proxy autoconfig.""" proxies = NSMutableDictionary.dictionaryWithDictionary_( self.ReadProxySettings()) logging.debug('initial proxy settings: %s', proxies) proxies['ProxyAutoConfigURLString'] = pac if enable: proxies['ProxyAutoConfigEnable'] = 1 else: proxies['ProxyAutoConfigEnable'] = 0 logging.debug('Setting ProxyAutoConfigURLString to %s and ' 'ProxyAutoConfigEnable to %s', pac, enable) result = SCDynamicStoreSetValue(self.store, 'State:/Network/Global/Proxies', proxies) logging.debug('final proxy settings: %s', self.ReadProxySettings()) return result
Example 2
Source File: socks.py From alibabacloud-python-sdk-v2 with Apache License 2.0 | 6 votes |
def set_proxy(self, proxy_type=None, addr=None, port=None, rdns=True, username=None, password=None): """ Sets the proxy to be used. proxy_type - The type of the proxy to be used. Three types are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS servers and 8080 for HTTP proxy servers. rdns - Should DNS queries be performed on the remote side (rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers. username - Username to authenticate with to the server. The default is no authentication. password - Password to authenticate with to the server. Only relevant when username is also provided.""" self.proxy = (proxy_type, addr, port, rdns, username.encode() if username else None, password.encode() if password else None)
Example 3
Source File: api.py From telepot with MIT License | 6 votes |
def set_proxy(url, basic_auth=None): """ Access Bot API through a proxy. :param url: proxy URL :param basic_auth: 2-tuple ``('username', 'password')`` """ global _pools, _onetime_pool_spec if not url: _pools['default'] = urllib3.PoolManager(**_default_pool_params) _onetime_pool_spec = (urllib3.PoolManager, _onetime_pool_params) elif basic_auth: h = urllib3.make_headers(proxy_basic_auth=':'.join(basic_auth)) _pools['default'] = urllib3.ProxyManager(url, proxy_headers=h, **_default_pool_params) _onetime_pool_spec = (urllib3.ProxyManager, dict(proxy_url=url, proxy_headers=h, **_onetime_pool_params)) else: _pools['default'] = urllib3.ProxyManager(url, **_default_pool_params) _onetime_pool_spec = (urllib3.ProxyManager, dict(proxy_url=url, **_onetime_pool_params))
Example 4
Source File: apis.py From XX-Net-mini with GNU General Public License v3.0 | 6 votes |
def set_proxy(args): xlog.info("set_proxy:%s", args) g.config.PROXY_ENABLE = args["enable"] g.config.PROXY_TYPE = args["type"] g.config.PROXY_HOST = args["host"] try: g.config.PROXY_PORT = int(args["port"]) except: g.config.PROXY_POT = 0 g.config.PROXY_USER = args["user"] g.config.PROXY_PASSWD = args["passwd"] g.config.save() connect_manager.load_proxy_config()
Example 5
Source File: socks.py From Malicious_Domain_Whois with GNU General Public License v3.0 | 6 votes |
def set_proxy(self, proxy_type=None, addr=None, port=None, rdns=True, username=None, password=None): """set_proxy(proxy_type, addr[, port[, rdns[, username[, password]]]]) Sets the proxy to be used. proxy_type - The type of the proxy to be used. Three types are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS servers and 8080 for HTTP proxy servers. rdns - Should DNS queries be performed on the remote side (rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers. username - Username to authenticate with to the server. The default is no authentication. password - Password to authenticate with to the server. Only relevant when username is also provided. """ self.proxy = (proxy_type, addr, port, rdns, username.encode() if username else None, password.encode() if password else None)
Example 6
Source File: connection.py From jarvis with GNU General Public License v2.0 | 6 votes |
def set_proxy_info(cls, proxy_host, proxy_port, proxy_type=PROXY_TYPE_HTTP, proxy_rdns=None, proxy_user=None, proxy_pass=None): '''Set proxy configuration for future REST API calls. :param str proxy_host: Hostname of the proxy to use. :param int proxy_port: Port to connect to. :param proxy_type: The proxy protocol to use. One of PROXY_TYPE_HTTP, PROXY_TYPE_SOCKS4, PROXY_TYPE_SOCKS5. Defaults to connection.PROXY_TYPE_HTTP. :param bool proxy_rdns: Use the proxy host's DNS resolver. :param str proxy_user: Username for the proxy. :param str proxy_pass: Password for the proxy. ''' cls._proxy_info = httplib2.ProxyInfo( proxy_type, proxy_host, proxy_port, proxy_rdns=proxy_rdns, proxy_user=proxy_user, proxy_pass=proxy_pass, )
Example 7
Source File: Connectivity.py From stonix with GNU General Public License v2.0 | 6 votes |
def set_proxy(self): '''This method configures the proxy for the outgoing connection based on the proxy set in localize.py (PROXY) @author: Breen Malmberg ''' ptype = 'https' psite = '' pport = '8080' sproxy = PROXY.split(':') if len(sproxy) == 3: ptype = sproxy[0] psite = sproxy[1].strip('/') pport = sproxy[2] proxy_handler = urllib.request.ProxyHandler({ptype : psite + ':' + pport}) opener = urllib.request.build_opener(proxy_handler) urllib.request.install_opener(opener) ###########################################################################
Example 8
Source File: stonixutilityfunctions.py From stonix with GNU General Public License v2.0 | 6 votes |
def set_no_proxy(): '''This method described here: http://www.decalage.info/en/python/urllib2noproxy to create a "no_proxy" environment for python @author: Roy Nielsen :returns: void @change: Breen Malmberg - 7/12/2017 - minor doc string edit; added try/except ''' try: proxy_handler = urllib.request.ProxyHandler({}) opener = urllib.request.build_opener(proxy_handler) urllib.request.install_opener(opener) except Exception: raise
Example 9
Source File: connection.py From qingcloud-sdk-python with Apache License 2.0 | 6 votes |
def set_proxy(self, host, port=None, headers=None, protocol="http"): """ set http (https) proxy @param host - the host to make the connection to proxy host @param port - the port to use when connect to proxy host @param header - using by https proxy. The headers argument should be a mapping of extra HTTP headers to send with the CONNECT request. @param protocol - 'http' or 'https' if protocol is https, set the host and the port for HTTP Connect Tunnelling. if protocol is http, Request-Uri is only absoluteURI. """ if protocol not in ["http", "https"]: raise Exception("%s is not supported" % protocol) self._proxy_host = host self._proxy_port = port self._proxy_headers = headers self._proxy_protocol = protocol
Example 10
Source File: base.py From coriolis with GNU Affero General Public License v3.0 | 6 votes |
def set_proxy(self, proxy_settings): url = proxy_settings.get('url') if not url: return username = proxy_settings.get('username') if username: password = proxy_settings.get('password', '') url = utils.get_url_with_credentials(url, username, password) LOG.debug("Proxy URL: %s", url) for var in ['http_proxy', 'https_proxy', 'ftp_proxy']: self._environment[var] = url # Some commands look for the uppercase var name self._environment[var.upper()] = url no_proxy = proxy_settings.get('no_proxy') if no_proxy: LOG.debug("Proxy exclusions: %s", no_proxy) self._environment["no_proxy"] = '.'.join(no_proxy)
Example 11
Source File: BDGExRequestHandler.py From DsgTools with GNU General Public License v2.0 | 6 votes |
def setUrllibProxy(self, url): """ Sets the proxy """ (enabled, host, port, user, password, type, urlsList) = self.getProxyConfiguration() if enabled == 'false' or type != 'HttpProxy': return for address in urlsList: if address in url: proxy = urllib.request.ProxyHandler({}) opener = urllib.request.build_opener(proxy, urllib.request.HTTPHandler) urllib.request.install_opener(opener) return proxyStr = 'http://'+user+':'+password+'@'+host+':'+port proxy = urllib.request.ProxyHandler({'http': proxyStr}) opener = urllib.request.build_opener(proxy, urllib.request.HTTPHandler) urllib.request.install_opener(opener) return
Example 12
Source File: socks.py From checkproxy with Apache License 2.0 | 6 votes |
def set_proxy(self, proxy_type=None, addr=None, port=None, rdns=True, username=None, password=None): """set_proxy(proxy_type, addr[, port[, rdns[, username[, password]]]]) Sets the proxy to be used. proxy_type - The type of the proxy to be used. Three types are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS servers and 8080 for HTTP proxy servers. rdns - Should DNS queries be performed on the remote side (rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers. username - Username to authenticate with to the server. The default is no authentication. password - Password to authenticate with to the server. Only relevant when username is also provided. """ self.proxy = (proxy_type, addr.encode(), port, rdns, username.encode() if username else None, password.encode() if password else None)
Example 13
Source File: httpclient.py From hprose-python with MIT License | 6 votes |
def setProxy(self, host, port = None): if host == None: self.__proxy = None else: proxy = urlparse.urlsplit(host) scheme = proxy[0] if port == None: if self.__scheme == 'https': port = 443 else: port = 80 netloc = proxy[1] if "@" in netloc: netloc = netloc.split("@", 1)[1] if ":" in netloc: netloc = netloc.split(":", 1) port = int(netloc[1]) netloc = netloc[0] host = netloc.lower() if host == 'localhost': ip = '127.0.0.1' else: ip = host self.__proxy = {'scheme': scheme, 'host': host, 'ip':ip, 'port': port}
Example 14
Source File: ProxyGuard.py From pilot with Apache License 2.0 | 6 votes |
def setX509UserProxy(self): """ reads and sets the name of the user proxy """ rc, rs = commands.getstatusoutput("echo $X509_USER_PROXY") if rc != 0: tolog("Could not get X509_USER_PROXY: %d, %s" % (rc, rs)) return False if rs == "": tolog("X509_USER_PROXY is not set") return False if not os.path.exists(rs): tolog("$X509_USER_PROXY does not exist: %s" % (rs)) return False self.x509_user_proxy = rs return True
Example 15
Source File: httpclient.py From azure-storage-python with MIT License | 6 votes |
def set_proxy(self, host, port, user, password): ''' Sets the proxy server host and port for the HTTP CONNECT Tunnelling. Note that we set the proxies directly on the request later on rather than using the session object as requests has a bug where session proxy is ignored in favor of environment proxy. So, auth will not work unless it is passed directly when making the request as this overrides both. :param str host: Address of the proxy. Ex: '192.168.0.100' :param int port: Port of the proxy. Ex: 6000 :param str user: User for proxy authorization. :param str password: Password for proxy authorization. ''' if user and password: proxy_string = '{}:{}@{}:{}'.format(user, password, host, port) else: proxy_string = '{}:{}'.format(host, port) self.proxies = {'http': 'http://{}'.format(proxy_string), 'https': 'https://{}'.format(proxy_string)}
Example 16
Source File: browser_mgmt.py From warriorframework with Apache License 2.0 | 6 votes |
def set_firefox_proxy(self, profile_dir, proxy_ip, proxy_port): """method to update the given preferences in Firefox profile""" # Create a default Firefox profile first and update proxy_ip and port ff_profile = webdriver.FirefoxProfile(profile_dir) proxy_port = int(proxy_port) ff_profile.set_preference("network.proxy.type", 1) ff_profile.set_preference("network.proxy.http", proxy_ip) ff_profile.set_preference("network.proxy.http_port", proxy_port) ff_profile.set_preference("network.proxy.ssl", proxy_ip) ff_profile.set_preference("network.proxy.ssl_port", proxy_port) ff_profile.set_preference("network.proxy.ftp", proxy_ip) ff_profile.set_preference("network.proxy.ftp_port", proxy_port) ff_profile.update_preferences() return ff_profile # private methods
Example 17
Source File: cran_package.py From depsy with MIT License | 6 votes |
def set_proxy_papers(self): url_template = "https://cran.r-project.org/web/packages/%s/citation.html" data_url = url_template % self.project_name print data_url response = requests.get(data_url, timeout=30) if response and response.status_code==200 and "<pre>" in response.text: page = response.text tree = html.fromstring(page) proxy_papers = str(tree.xpath('//pre/text()')) print "found proxy paper!" # print proxy_papers else: print "no proxy paper found" proxy_papers = "No proxy paper" self.proxy_papers = proxy_papers #useful info: http://www.r-pkg.org/services
Example 18
Source File: internetoptions.py From cvpysdk with Apache License 2.0 | 6 votes |
def set_http_proxy(self, servername=None, port=None): """ sets HTTP proxy enabled with the provided server name and port Args: servername (str): hostname or IP of the HTTP proxy server port (int): HTTP proxy server port Raises: SDKException: if proxy server name and port are empty """ if servername is None or port is None: raise SDKException('Response', '101', 'proxy server name and port cannot be empty') self._config['useHttpProxy'] = True self._config['proxyServer'] = servername self._config['proxyPort'] = int(port) self._save_config()
Example 19
Source File: localProxyServerHandler.py From DDDProxy with Apache License 2.0 | 6 votes |
def setToProxyMode(self, host=None, port=None): if self.mode == "proxy": return self.mode = "proxy" connect = localToRemoteConnectManger.getConnect() if host: try: connect = localToRemoteConnectManger.getConnectHost(host, port) except: pass if connect: connect.addLocalRealConnect(self) self.connectName = connect.filenoStr() + " < " + self.connectName return True else: self.close() return False
Example 20
Source File: environment.py From Mobile-Security-Framework-MobSF with GNU General Public License v3.0 | 6 votes |
def set_global_proxy(self, version): """Set Global Proxy on device.""" # Android 4.4+ supported proxy_ip = None proxy_port = settings.PROXY_PORT if version < 5: proxy_ip = get_proxy_ip(self.identifier) else: proxy_ip = settings.PROXY_IP if proxy_ip: if version < 4.4: logger.warning('Please set Android VM proxy as %s:%s', proxy_ip, proxy_port) return logger.info('Setting Global Proxy for Android VM') self.adb_command( ['settings', 'put', 'global', 'http_proxy', '{}:{}'.format(proxy_ip, proxy_port)], True)
Example 21
Source File: HttpProxyMiddleware.py From HttpProxyMiddleware with MIT License | 6 votes |
def set_proxy(self, request): """ 将request设置使用为当前的或下一个有效代理 """ proxy = self.proxyes[self.proxy_index] if not proxy["valid"]: self.inc_proxy_index() proxy = self.proxyes[self.proxy_index] if self.proxy_index == 0: # 每次不用代理直接下载时更新self.last_no_proxy_time self.last_no_proxy_time = datetime.now() if proxy["proxy"]: request.meta["proxy"] = proxy["proxy"] elif "proxy" in request.meta.keys(): del request.meta["proxy"] request.meta["proxy_index"] = self.proxy_index proxy["count"] += 1
Example 22
Source File: NeteaseMusicProxy.py From NeteaseMusicAbroad with The Unlicense | 6 votes |
def set_proxy(self): r = requests.get("http://cn-proxy.com/") q = PyQuery(r.content) trs = q("tbody tr") if (len(trs) == 0): self.ip = self.default_ip self.port = self.default_port return tr = trs[min(self.failed_times,len(trs)-1)] trq = PyQuery(tr) tds = trq.children() ip = tds.eq(0).text() port = int(tds.eq(1).text()) if self.ip == ip and self.port == port: self.set_to_default() else: self.ip = ip self.port = port
Example 23
Source File: socks.py From HTTPAceProxy with GNU General Public License v3.0 | 6 votes |
def set_proxy(self, proxy_type=None, addr=None, port=None, rdns=True, username=None, password=None): """ Sets the proxy to be used. proxy_type - The type of the proxy to be used. Three types are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS servers and 8080 for HTTP proxy servers. rdns - Should DNS queries be performed on the remote side (rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers. username - Username to authenticate with to the server. The default is no authentication. password - Password to authenticate with to the server. Only relevant when username is also provided.""" self.proxy = (proxy_type, addr, port, rdns, username.encode() if username else None, password.encode() if password else None)
Example 24
Source File: win32_proxy_manager.py From oss-ftp with MIT License | 6 votes |
def set_proxy_server(ip, port): setting = create_unicode_buffer(ip+":"+str(port)) List = INTERNET_PER_CONN_OPTION_LIST() Option = (INTERNET_PER_CONN_OPTION * 3)() nSize = c_ulong(sizeof(INTERNET_PER_CONN_OPTION_LIST)) Option[0].dwOption = INTERNET_PER_CONN_FLAGS Option[0].Value.dwValue = PROXY_TYPE_DIRECT | PROXY_TYPE_PROXY Option[1].dwOption = INTERNET_PER_CONN_PROXY_SERVER Option[1].Value.pszValue = setting Option[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS Option[2].Value.pszValue = create_unicode_buffer("localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;172.32.*;192.168.*") List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST) List.pszConnection = None List.dwOptionCount = 3 List.dwOptionError = 0 List.pOptions = Option InternetSetOption(None, INTERNET_OPTION_PER_CONNECTION_OPTION, byref(List), nSize) InternetSetOption(None, INTERNET_OPTION_SETTINGS_CHANGED, None, 0) InternetSetOption(None, INTERNET_OPTION_REFRESH, None, 0)
Example 25
Source File: win32_proxy_manager.py From oss-ftp with MIT License | 6 votes |
def set_proxy_auto(pac_url): setting = create_unicode_buffer(pac_url) List = INTERNET_PER_CONN_OPTION_LIST() Option = (INTERNET_PER_CONN_OPTION * 3)() nSize = c_ulong(sizeof(INTERNET_PER_CONN_OPTION_LIST)) Option[0].dwOption = INTERNET_PER_CONN_FLAGS Option[0].Value.dwValue = PROXY_TYPE_DIRECT | PROXY_TYPE_AUTO_PROXY_URL Option[1].dwOption = INTERNET_PER_CONN_AUTOCONFIG_URL Option[1].Value.pszValue = setting Option[2].dwOption = INTERNET_PER_CONN_PROXY_BYPASS Option[2].Value.pszValue = create_unicode_buffer("localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;172.32.*;192.168.*") List.dwSize = sizeof(INTERNET_PER_CONN_OPTION_LIST) List.pszConnection = None List.dwOptionCount = 3 List.dwOptionError = 0 List.pOptions = Option InternetSetOption(None, INTERNET_OPTION_PER_CONNECTION_OPTION, byref(List), nSize) InternetSetOption(None, INTERNET_OPTION_SETTINGS_CHANGED, None, 0) InternetSetOption(None, INTERNET_OPTION_REFRESH, None, 0)
Example 26
Source File: com.py From cWMI with Apache License 2.0 | 6 votes |
def set_proxy_blanket(self, proxy, auth_svc=winapi.RPC_C_AUTHN_WINNT, authz_svc=winapi.RPC_C_AUTHZ_NONE, name=None, auth_level=winapi.RPC_C_AUTHN_LEVEL_CALL, imp_level=winapi.RPC_C_IMP_LEVEL_IMPERSONATE, auth_info=None, capabilities=winapi.EOAC_NONE): winapi.CoSetProxyBlanket(proxy, auth_svc, authz_svc, name, auth_level, imp_level, auth_info, capabilities)
Example 27
Source File: crawler.py From ITWSV with MIT License | 6 votes |
def set_proxy(self, proxy=""): """Set a proxy to use for HTTP requests.""" url_parts = urlparse(proxy) protocol = url_parts.scheme.lower() if protocol in ("http", "https", "socks"): if protocol == "socks": # socks5h proxy type won't leak DNS requests proxy = urlunparse(("socks5h", url_parts.netloc, '/', '', '', '')) else: proxy = urlunparse((url_parts.scheme, url_parts.netloc, '/', '', '', '')) # attach the proxy for http and https URLs self._session.proxies["http"] = proxy self._session.proxies["https"] = proxy else: raise ValueError("Unknown proxy type '{}'".format(protocol))
Example 28
Source File: provider.py From xalpha with MIT License | 6 votes |
def set_proxy(proxy=None): """ 设置代理,部分数据源可能国内网络环境不稳定。比如标普指数官网。 还有一些数据源很快就会封 IP,需要设置代理,比如人民币中间价官网,建议直接把中间价数据缓存到本地,防止反复爬取。 :param proxy: str. format as "http://user:passwd@host:port" user passwd part can be omitted if not set. None 代表取消代理 :return: """ if proxy: os.environ["http_proxy"] = proxy os.environ["https_proxy"] = proxy setattr(thismodule, "proxy", proxy) else: os.environ["http_proxy"] = "" os.environ["https_proxy"] = "" setattr(thismodule, "proxy", None)
Example 29
Source File: job.py From misp42splunk with GNU Lesser General Public License v3.0 | 6 votes |
def set_proxy(self, proxy_setting): """ Setup the proxy setting. :param proxy_setting: Proxy setting should include the following fields "proxy_enabled": , "proxy_url":, "proxy_port": , "proxy_username": , "proxy_password": , "proxy_rdns": , "proxy_type": , :type proxy_setting: ``dict`` """ self._proxy_info = proxy_setting logger.debug("CCEJob proxy info: proxy_enabled='%s', proxy_url='%s', " "proxy_port='%s', proxy_rdns='%s', proxy_type='%s', " "proxy_username='%s'", proxy_setting.get("proxy_enabled"), proxy_setting.get("proxy_url"), proxy_setting.get("proxy_port"), proxy_setting.get("proxy_rdns"), proxy_setting.get("proxy_type"), proxy_setting.get("proxy_username"))
Example 30
Source File: socks.py From plugin.video.kmediatorrent with GNU General Public License v3.0 | 6 votes |
def set_proxy(self, proxy_type=None, addr=None, port=None, rdns=True, username=None, password=None): """set_proxy(proxy_type, addr[, port[, rdns[, username[, password]]]]) Sets the proxy to be used. proxy_type - The type of the proxy to be used. Three types are supported: PROXY_TYPE_SOCKS4 (including socks4a), PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP addr - The address of the server (IP or DNS). port - The port of the server. Defaults to 1080 for SOCKS servers and 8080 for HTTP proxy servers. rdns - Should DNS queries be performed on the remote side (rather than the local side). The default is True. Note: This has no effect with SOCKS4 servers. username - Username to authenticate with to the server. The default is no authentication. password - Password to authenticate with to the server. Only relevant when username is also provided. """ self.proxy = (proxy_type, addr.encode(), port, rdns, username.encode() if username else None, password.encode() if password else None)
Example 31
Source File: v2net.py From v2net with GNU General Public License v3.0 | 5 votes |
def set_proxy_menu(q_action): global system if q_action.isChecked(): system = True # set_proxy() threading.Thread(target=set_proxy).start() SETTING.write('Global', 'system', 'true') else: system = False # set_proxy() threading.Thread(target=set_proxy).start() SETTING.write('Global', 'system', 'false')
Example 32
Source File: _urllib2_fork.py From BruteXSS with GNU General Public License v3.0 | 5 votes |
def set_proxy(self, host, type): orig_host = self.get_host() if self.get_type() == 'https' and not self._tunnel_host: self._tunnel_host = orig_host else: self.type = type self.__r_host = self.__original self.host = host
Example 33
Source File: remoteproxy.py From tf-pose with Apache License 2.0 | 5 votes |
def setProxyOptions(self, **kwds): """ Set the default behavior options for object proxies. See ObjectProxy._setProxyOptions for more info. """ with self.optsLock: self.proxyOptions.update(kwds)
Example 34
Source File: sender.py From AdslProxy with MIT License | 5 votes |
def set_proxy(self, proxy): """ 设置代理 :param proxy: 代理 :return: None """ self.redis = RedisClient() if self.redis.set(CLIENT_NAME, proxy): print('Successfully Set Proxy', proxy)
Example 35
Source File: main.py From CNCGToolKit with MIT License | 5 votes |
def setProxy(self,b): """self.setProxy(b) -> None. Set proxy. @param b: Boolean convertible object. @return: None. """ pass
Example 36
Source File: socks.py From checkproxy with Apache License 2.0 | 5 votes |
def set_default_proxy(proxy_type=None, addr=None, port=None, rdns=True, username=None, password=None): """ set_default_proxy(proxy_type, addr[, port[, rdns[, username, password]]]) Sets a default proxy which all further socksocket objects will use, unless explicitly changed. """ socksocket.default_proxy = (proxy_type, addr.encode(), port, rdns, username.encode() if username else None, password.encode() if password else None)
Example 37
Source File: socks.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 5 votes |
def set_default_proxy(proxy_type=None, addr=None, port=None, rdns=True, username=None, password=None): """ set_default_proxy(proxy_type, addr[, port[, rdns[, username, password]]]) Sets a default proxy which all further socksocket objects will use, unless explicitly changed. All parameters are as for socket.set_proxy(). """ socksocket.default_proxy = (proxy_type, addr, port, rdns, username.encode() if username else None, password.encode() if password else None)
Example 38
Source File: Instagram.py From Instagram-API with MIT License | 5 votes |
def setProxy(self, proxy, port=None, username=None, password=None): """ Set the proxy. :type proxy: str :param proxy: Full proxy string. Ex: user:pass@192.168.0.0:8080 Use $proxy = "" to clear proxy :type port: int :param port: Port of proxy :type username: str :param username: Username for proxy :type password: str :param password: Password for proxy :raises: InstagramException """ self.proxy = proxy if proxy == '': return proxy = parse_url(proxy) if port and isinstance(port, int): proxy['port'] = int(port) if username and password: proxy['user'] = username proxy['pass'] = password if proxy['host'] and proxy['port'] and isinstance(proxy['port'], int): self.proxyHost = proxy['host'] + ':' + proxy['port'] else: raise InstagramException('Proxy host error. Please check ip address and port of proxy.') if proxy['user'] and proxy['pass']: self.proxyAuth = proxy['user'] + ':' + proxy['pass']
Example 39
Source File: __init__.py From pornhub-api with MIT License | 5 votes |
def setProxyDictionary(self, ProxyIP, ProxyPort): if ProxyIP == None or ProxyPort == None: self.ProxyDictionary = {} else: Address = "://" + ProxyIP + ":" + str(ProxyPort) self.ProxyDictionary = { "http" : "http" + Address, "https" : "https" + Address }
Example 40
Source File: crawler.py From icrawler with MIT License | 5 votes |
def set_proxy_pool(self, pool=None): """Construct a proxy pool By default no proxy is used. Args: pool (ProxyPool, optional): a :obj:`ProxyPool` object """ self.proxy_pool = ProxyPool() if pool is None else pool