mitmproxy的事件(二)

主题
         修改request或者response内容

介绍
          mitmdump无交互界面的命令,与python脚本对接,来源于mitmproxy支持inline script,这里的script指的是python脚本,inline script提供了http、Websocket、tcp等各个时间点事件(events)的hook函数,如http中的request、response等

主要events一览表
         需要修改各种事件内容时,重写以下对应方法,这里主要用的是request、response方法

 

def clientconnect(self, root_layer):
    pass
 
def clientdisconnect(self, root_layer):
    pass
 
def serverconnect(self, server_conn):
    pass
 
def serverdisconnect(self, server_conn):
    pass
 
def next_layer(self, top_layer):
    pass
 
def http_connect(self, f):
    pass
 
def error(self, f):
    pass
 
def requestheaders(self, f):
    pass
 
def request(self, f):
    pass
 
def responseheaders(self, f):
    pass
 
def response(self, f):
    pass
 
def websocket_handshake(self, f):
    pass
 
def websocket_start(self, flow):
    pass
 
def websocket_message(self, flow):
    pass
 
def websocket_error(self, flow):
    pass
 
def websocket_end(self, flow):
    pass
 
def tcp_start(self, flow):
    pass
 
def tcp_message(self, flow):
    pass
 
def tcp_error(self, flow):
    pass
 
def tcp_end(self, flow):
    pass
 

你可能感兴趣的:(爬虫)