fiddler自動保存請求報文


先來看一張自動保存的請求片段

 

 

 

重點來了,下面是實現的js代碼

操作步驟

  • Fiddler菜單 >> Rules >> Customize Rules
  • 如果提示沒有下載Fiddler ScriptEditor則按提示下載后進入下一步操作
  • 安裝好Fiddler ScriptEditor后,就能打開Customize Rules.js文件
  • 編輯Customize Rules.js文件,並保存
  • 重啟fiddler

保存Request

把下面代碼貼在OnBeforeRequest()方法末尾

//過濾無關請求,只關注特定請求 if (oSession.fullUrl.Contains("szhome.com")) { var fso; var file; fso = new ActiveXObject("Scripting.FileSystemObject"); //文件保存路徑,可自定義 file = fso.OpenTextFile("D:\\Fiddler Sessions\\Sessions.txt",8 ,true, true); file.writeLine("Request url: " + oSession.url); file.writeLine("Request header:" + "\n" + oSession.oRequest.headers); file.writeLine("Request body: " + oSession.GetRequestBodyAsString()); file.writeLine("\n"); file.close(); } 

保存Response

把下面代碼貼在OnBeforeResponse()方法末尾

//過濾無關請求,只關注特定請求 if (oSession.fullUrl.Contains("szhome.com")) { oSession.utilDecodeResponse();//消除保存的請求可能存在亂碼的情況 var fso; var file; fso = new ActiveXObject("Scripting.FileSystemObject"); //文件保存路徑,可自定義 file = fso.OpenTextFile("D:\\Fiddler Sessions\\Sessions.txt",8 ,true, true); file.writeLine("Response code: " + oSession.responseCode); file.writeLine("Response body: " + oSession.GetResponseBodyAsString()); file.writeLine("\n"); file.close(); }


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM