相关疑难解决方法(0)

在Twisted中将HTTP代理转换为HTTPS代理

最近我一直在使用扭曲的HTTP代理.经过多次反复试验后,我想我终于有了一些工作.我想知道的是,如果有可能,我是否可以扩展此代理以便能够处理HTTPS页面?这是我到目前为止所得到的:

from twisted.internet import reactor
from twisted.web import http
from twisted.web.proxy import Proxy, ProxyRequest, ProxyClientFactory, ProxyClient



class HTTPProxyClient(ProxyClient):
    def handleHeader(self, key, value):
        print "%s : %s" % (key, value)
        ProxyClient.handleHeader(self, key, value)

    def handleResponsePart(self, buffer):
        print buffer
        ProxyClient.handleResponsePart(self, buffer)

class HTTPProxyFactory(ProxyClientFactory):
    protocol = HTTPProxyClient

class HTTPProxyRequest(ProxyRequest):
    protocols = {'http' : HTTPProxyFactory}

    def process(self):
        print self.method
        for k,v in self.requestHeaders.getAllRawHeaders():
            print "%s : %s" % (k,v)
        print "\n \n"

        ProxyRequest.process(self)

class HTTPProxy(Proxy):

    requestFactory = HTTPProxyRequest


factory = http.HTTPFactory()
factory.protocol = HTTPProxy …
Run Code Online (Sandbox Code Playgroud)

python https proxy http twisted

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

http ×1

https ×1

proxy ×1

python ×1

twisted ×1