在cshare中命名空间名称FiddlerUtility,然后写静态变量OnBeforeRequest,OnBeforeResponse
using System;
using Fiddler;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using System.Collections.Generic;
namespace Fiddler
{
public static class Handlers
{
public static void OnBeforeRequest(Session oSession)
{
var getDataDomain = "www.baidu.com";
if (!oSession.HostnameIs(getDataDomain))
{
//FiddlerObject.alert("true");
//oSession["ui-hide"] = "false";
}
//获取提交返回的授权信息
if(oSession.uriContains(getDataDomain))
{
var Authorization = oSession.RequestHeaders["Authorization"];
if (!String.IsNullOrWhiteSpace(Authorization))
{
var authSession = "Authorization: " + Authorization;
FiddlerApplication.UI.SetStatusText(authSession);
System.IO.File.WriteAllText(@"D:\Users\Desktop\httpdata\test2.txt", authSession , Encoding.UTF8);
}
}
}
public static void OnBeforeResponse(Session oSession)
{
//获取提交返回的授权信息
if(oSession.uriContains("www.baidu.com"))
{
var strResponseBody = oSession.GetResponseBodyAsString();
FiddlerObject.alert(strResponseBody);
if (!String.IsNullOrWhiteSpace(strResponseBody))
{
// var strResponseBody = "Authorization: " + Authorization;
// FiddlerApplication.UI.SetStatusText(authSession);
FiddlerObject.alert(strResponseBody);
System.IO.File.WriteAllText(@"D:\Users\Desktop\httpdata\test3.txt", strResponseBody , Encoding.UTF8);
}
}
}
public static void Main(){}
}
}
编译:
csc /target:library /out:D:\Users\Desktop\FiddlerExt\FiddlerHandle.dll D:\Users\Desktop\FiddlerExt\FiddlerHandle.cs /reference:"C:\Users\Administrator\AppData\local\Programs\Fiddler\Fiddler.exe"
在fiddler界面的js.net添加
import FiddlerUtility;
在OnBeforeRequest函数中添加。
FiddlerHandle.OnBeforeRequest(oSession,"D:\\Users\\Desktop\\httpdata");
在OnBeforeResponse函数中添加。
FiddlerHandle.OnBeforeResponse(oSession,"D:\\Users\\Desktop\\httpdata");
原文:https://www.cnblogs.com/partman/p/11284511.html