我更新到 MITMProxy 版本 5.2。更新后,我嘗試運行舊腳本并不斷收到錯誤:AttributeError: 'HTTPResponse' object has no attribute 'replace'從我的代碼來看:flow.response.replace('FindThis', 'ReplaceWithThis')我讀到他們更改了替換,但找不到任何明確說明其更改內容或腳本中正確語法的文檔。我讀到ModifyBodywas a replacement,但是當我將腳本從 更改replace為時ModifyBody,我會收到錯誤:AttributeError: 'HTTPResponse' object has no attribute 'ModifyBody'所以我認為它不正確或者我需要加載模塊?我想知道是否有新的或相同的語法。
1 回答
30秒到達戰場
TA貢獻1828條經驗 獲得超6個贊
我們刪除了HTTPResponse.replace,因為并不清楚哪些部分(標題、內容)是如何替換的。實際上:
用于
flow.response.content = flow.response.content.replace(b"foo", b"bar")在響應正文中進行二進制替換。用于
flow.response.text = flow.response.text.replace("foo", "bar")在響應正文中進行文本替換。用作
flow.headers字典來進行標頭替換,例如flow.headers["foo"] = "42".
添加回答
舉報
0/150
提交
取消
