有一个这样的需求:Fiddler抓包以后把抓到的资源文件按照请求路径保存到本地。
方法是点击菜单栏Rules-Customize rules...找到函数OnBeforeResponse
替换成如下代码:
static function OnBeforeResponse(oSession: Session) {
if (m_Hide304s && oSession.responseCode == 304) {
oSession["ui-hide"] = "true";
}
//这里自己设置过滤网址条件
if (oSession.PathAndQuery.ToLower().Contains("xxx") && oSession.hostname.ToLower().Equals("myhost.cn"))
{
//这里一般设置条件为oSession.responseCode == 200即可
if(oSession.responseCode >= 200 && oSession.responseCode <= 300)
{
//设置存放的文件夹路径
var directory2 = "D:\\mylocalpath\\";
var filename2 = oSession.oRequest.headers.RequestPath.Substring(1);
var path2: String = System.IO.Path.Combine(directory2, filename2);
FiddlerApplication.Log.LogString("path2="+path2);
oSession.SaveResponseBody(path2);
}
}
}
倾情致谢虾米提供解决方案(づ ̄ 3 ̄)づ
网友评论