美文网首页
fiddler 将固定得相应请求和响应保存到本地

fiddler 将固定得相应请求和响应保存到本地

作者: 羽天驿 | 来源:发表于2021-04-16 17:16 被阅读0次

    一。Rules--->customize rules

    第一部分(响应)
    static function OnBeforeResponse(oSession: Session) {
            //过滤无关请求,只关注特定请求 
            if (oSession.fullUrl.Contains("请填入url")) { 
                oSession.utilDecodeResponse();
                //消除保存的请求可能存在乱码的情况 
                var fso; 
                var file; 
                fso = new ActiveXObject("Scripting.FileSystemObject"); 
                //文件保存路径,可自定义 
                file = fso.OpenTextFile("D:\\sprider_fiddler_data\\data_counts.txt",8 ,true, true); 
                //file.writeLine("Response code: " + oSession.responseCode); 
                file.writeLine("Response_body:"+oSession.GetResponseBodyAsString()); 
                //file.writeLine("\n"); 
                file.close(); 
    
            }
            if (oSession.fullUrl.Contains("请填入url")) { 
                oSession.utilDecodeResponse();
                //消除保存的请求可能存在乱码的情况 
                var fso; 
                var file; 
                fso = new ActiveXObject("Scripting.FileSystemObject"); 
                //文件保存路径,可自定义 
                file = fso.OpenTextFile("D:\\sprider_fiddler_data\\data_content.txt",8 ,true, true); 
                //file.writeLine("Response code: " + oSession.responseCode); 
                file.writeLine("Response_body:"+oSession.GetResponseBodyAsString()); 
                //file.writeLine("\n"); 
                file.close(); 
    }
    
    #第二部分(请求)
     static function OnBeforeRequest(oSession: Session) {
            // Sample Rule: Color ASPX requests in RED
            // if (oSession.uriContains(".aspx")) { oSession["ui-color"] = "red";   }
    
            // Sample Rule: Flag POSTs to fiddler2.com in italics
            // if (oSession.HostnameIs("www.fiddler2.com") && oSession.HTTPMethodIs("POST")) {  oSession["ui-italic"] = "yup";  }
    
            // Sample Rule: Break requests for URLs containing "/sandbox/"
            // if (oSession.uriContains("/sandbox/")) {
            //     oSession.oFlags["x-breakrequest"] = "yup";   // Existence of the x-breakrequest flag creates a breakpoint; the "yup" value is unimportant.
            // }
            //过滤无关请求,只关注特定请
            if (oSession.fullUrl.Contains("请填入url")) { 
                var fso;
                var file; 
                fso = new ActiveXObject("Scripting.FileSystemObject");
                //文件保存路径,可自定义 
                file = fso.OpenTextFile("D:\\sprider_fiddler_data\\data_counts.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(); 
    
            }
            if (oSession.fullUrl.Contains("请填入url")) { 
                var fso;
                var file; 
                fso = new ActiveXObject("Scripting.FileSystemObject");
                //文件保存路径,可自定义 
                file = fso.OpenTextFile("D:\\sprider_fiddler_data\\data_content.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(); 
    
            }
    
    
    

    相关文章

      网友评论

          本文标题:fiddler 将固定得相应请求和响应保存到本地

          本文链接:https://www.haomeiwen.com/subject/idwelltx.html