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


Python proxy.Proxy方法代碼示例

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


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

示例1: dataReceived

# 需要導入模塊: from twisted.web import proxy [as 別名]
# 或者: from twisted.web.proxy import Proxy [as 別名]
def dataReceived(self, request):
        try:
            headers,content = Parser(request.decode())
            url = content['resource']
            host = headers['Host']
            client_ip = str(self.transport.getPeer().host)
            date = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            useragent = headers['User-Agent']
            result = Handler(date,request,host,url,client_ip,useragent)
            if result == 'Safe':
                return proxy.Proxy.dataReceived(self, request)
            else:
                return proxy.Proxy.dataReceived(self, b'GET http://house.proxy:8000/redirect HTTP/1.1\r\nHost: house.proxy:8000\r\n\r\n')
        except Exception as e:
            pass 
開發者ID:mthbernardes,項目名稱:HouseProxy,代碼行數:17,代碼來源:houseProxy.py

示例2: requestDone

# 需要導入模塊: from twisted.web import proxy [as 別名]
# 或者: from twisted.web.proxy import Proxy [as 別名]
def requestDone(self, request):
		if request.method == b'CONNECT' and self.connectedRemote is not None:
			self.connectedRemote.connectedClient = self
			self._handlingRequest = False
			if self._savedTimeOut:
				self.setTimeout(self._savedTimeOut)
			data = b''.join(self._dataBuffer)
			self._dataBuffer = []
			self.setLineMode(data)
		else:
			proxy.Proxy.requestDone(self, request) 
開發者ID:yi-ji,項目名稱:NeteaseMusicAbroad,代碼行數:13,代碼來源:NeteaseMusicProxy.py

示例3: dataReceived

# 需要導入模塊: from twisted.web import proxy [as 別名]
# 或者: from twisted.web.proxy import Proxy [as 別名]
def dataReceived(self, data):
		if self.connectedRemote is None:
			proxy.Proxy.dataReceived(self, data)
		else:
			self.connectedRemote.transport.write(data) 
開發者ID:yi-ji,項目名稱:NeteaseMusicAbroad,代碼行數:7,代碼來源:NeteaseMusicProxy.py

示例4: process

# 需要導入模塊: from twisted.web import proxy [as 別名]
# 或者: from twisted.web.proxy import Proxy [as 別名]
def process(self):
        host = None
        port = None
        parsed_uri = urlparse(self.uri)
        self.uri = urlunparse(('', '', parsed_uri.path, parsed_uri.params, parsed_uri.query, parsed_uri.fragment)) or "/"

        if self.has_request_modifiers():
            self.run_request_modifiers()
            
        if self.has_response_server():
            self.serve_resource()
            return 
            
        protocol = parsed_uri.scheme or 'http'
        host = host or parsed_uri.netloc
        port = port or parsed_uri.port or self.ports[protocol]

        headers = self.getAllHeaders().copy()
        if 'host' not in headers:
            headers['host'] = host
             
        if ':' in host:
            host,_ = host.split(':')

        self.content.seek(0, 0)
        content = self.content.read()
    
        clientFactory = InterceptingProxyClientFactory(self.method, self.uri, self.clientproto, headers, content, self)
        self.reactor.connectTCP(host, port, clientFactory)

#Proxy(twisted.web.http.HTTPChannel) 
開發者ID:pdjstone,項目名稱:wsuspect-proxy,代碼行數:33,代碼來源:intercepting_proxy.py

示例5: __init__

# 需要導入模塊: from twisted.web import proxy [as 別名]
# 或者: from twisted.web.proxy import Proxy [as 別名]
def __init__(self, wordCounter):
        self.wordCounter = wordCounter
        proxy.Proxy.__init__(self) 
開發者ID:ScrappyZhang,項目名稱:python_web_Crawler_DA_ML_DL,代碼行數:5,代碼來源:t48_http_proxy_wordcount.py

示例6: buildProtocol

# 需要導入模塊: from twisted.web import proxy [as 別名]
# 或者: from twisted.web.proxy import Proxy [as 別名]
def buildProtocol(self, addr):
        return Proxy() 
開發者ID:TeamHG-Memex,項目名稱:autologin,代碼行數:4,代碼來源:proxy.py

示例7: main

# 需要導入模塊: from twisted.web import proxy [as 別名]
# 或者: from twisted.web.proxy import Proxy [as 別名]
def main():
    http_port = reactor.listenTCP(PROXY_PORT, ProxyFactory())
    def print_listening():
        host = http_port.getHost()
        print('Proxy server running at http://{}:{}'.format(
            host.host, host.port))
    reactor.callWhenRunning(print_listening)
    reactor.run() 
開發者ID:TeamHG-Memex,項目名稱:autologin,代碼行數:10,代碼來源:proxy.py


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