当前位置: 首页>>代码示例>>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;未经允许,请勿转载。