<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] <br> ### FiddlerScript 介紹 FiddlerScript提供了請求/響應過程中的事件接口,通過這些接口,我們可以編寫代碼,注冊自定義邏輯 打開FiddlerScript編輯器 方式一:通過【Rules】->【Customize Rules】 打開Fiddler ScriptEditor 方式二:通過右側菜單“FiddlerScript”Tab頁進入FiddlerScript編輯器 ![](https://box.kancloud.cn/95936bd998f7750aeeaed549a8d9711e_619x655.jpg) 我喜歡通過方式二進行編輯,通過Go to 可以跳轉定位到關鍵的系統方法中。 **FiddlerScript中最關鍵的兩個方法:** - OnBeforeRequest:每次請求之前調用 - OnBeforeResponse:每次響應之前調用 ### 修改請求信息 在OnBeforeRequest函數中,添加代碼片段: ```python // 域名替換,將一臺服務器的所有請求指向另一臺服務器上的同一端口 if (oSession.HostnameIs("www.bayden.com")) { oSession.hostname="test.bayden.com"; } // 域名與端口替換 if (oSession.host=="www.bayden.com:8080") { oSession.host="test.bayden.com:9090"; } // 域名替換, 包含HTTPS傳輸協議 if (oSession.HTTPMethodIs("CONNECT") && (oSession.PathAndQuery == "www.example.com:443")) { oSession.PathAndQuery = "beta.example.com:443"; } if (oSession.HostnameIs("www.example.com")) oSession.hostname = "beta.example.com"; // 修改host,將域名映射到指定IP if (oSession.HostnameIs("subdomain.example.com")){ oSession.bypassGateway = true; // Prevent this request from going through an upstream proxy oSession["x-overrideHost"] = "128.123.133.123"; // DNS name or IP address of target server } // 將單個頁面的請求重新定位到不同的頁面,可能位于不同的服務器上。 (通過更改請求的主機頭來重新定位) if (oSession.url=="www.example.com/live.js") { oSession.url = "dev.example.com/workinprogress.js"; } // 添加 header oSession.oRequest["NewHeaderName"] = "New header value"; // 阻止發送cookie oSession.oRequest.headers.Remove("Cookie"); //修改請求url if (oSession.uriContains("notice/recover")) { oSession.fullUrl="https://api.test.com/notice/recover?k1=v1&k2=v2" // 修改post請求的boby var strBody=oSession.GetRequestBodyAsString(); // 獲取請求中的body字符串 strBody=strBody.replace("1111","2222"); FiddlerObject.alert(strBody);// 彈個對話框檢查下修改后的body oSession.utilSetRequestBody(strBody); // 修改JSON參數 if(oSession.fullUrl.Contains("notice/recover")){ var new_data='{"user":"123456","pwd":"ba59be56e0abe10a4957f20fdc39883e","captcha":null}';//更改后的JSON數據 var requestJson=Fiddler.WebFormats.JSON.JsonDecode(new_data); var reJsonDes=Fiddler.WebFormats.JSON.JsonEncode(requestJson.JSONObject); oSession.utilSetRequestBody(reJsonDes); } ``` ### 修改響應信息 在OnBeforeResponse函數中,添加代碼片段: ```python // 從響應HTML中查找和替換 if (oSession.HostnameIs("www.bayden.com") && oSession.oResponse.headers.ExistsAndContains("Content-Type","text/html")){ oSession.utilDecodeResponse(); //解碼 oSession.utilReplaceInResponse('<b>','<u>'); } // 修改響應boby,如修改Result值1更改為2 if (oSession.uriContains("notice/recover")) { var bobystr = oSession.GetResponseBodyAsString(); bobystr = bobystr.Replace("\"Result\":1","\"Result\":2"); oSession.utilSetResponseBody(bobystr); } // 修改JSON返回值 if(oSession.fullUrl.Contains("notice/recover")){ var reponseJsonString=oSession.GetResponseBodyAsString();//獲取JSON字符串 var responseJSON=Fiddler.WebFormats.JSON.JsonDecode(reponseJsonString);//轉化為JSON數據,可編輯 var str='{"code":"1"}';//自定義JSON responseJSON.JSONObject['data']= Fiddler.WebFormats.JSON.JsonDecode(str).JSONObject;//轉換需要 var myResponseJSON= Fiddler.WebFormats.JSON.JsonEncode(responseJSON.JSONObject);//轉換需要 oSession.utilSetResponseBody(myResponseJSON);//設置ResponseBody中的JSON數據 } ``` ### 更多 更多信息,請查看官方文檔[https://docs.telerik.com/fiddler/KnowledgeBase/FiddlerScript/ModifyRequestOrResponse](https://docs.telerik.com/fiddler/KnowledgeBase/FiddlerScript/ModifyRequestOrResponse) <hr style="margin-top:100px"> :-: ![](https://box.kancloud.cn/331f659e8e6cddb0d9f182e00e32803f_258x258.jpg) ***微信掃一掃,關注“python測試開發圈”,獲取更多測試開發分享!***
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看