Fiddler Script
作者:互联网
1、编写FiddlerScript
FiddlerScript 基于JScript.NET 语言。在Fiddler 中点击菜单“Rules > Customize Rules”打开FiddlerScript Editor 编辑器,在这里可以编写Fiddler Script 脚本可以
使用FiddlerScript Editor编辑器,因为它具有语法高亮以及自动完成功能,下载地址http://fiddler2.com/fiddlerscript-editor。
2、脚本编写
static function OnBeforeResponse(oSession: Session) { if (m_Hide304s && oSession.responseCode == 304) { oSession["ui-hide"] = "true"; } if ( oSession.fullUrl.Contains("api5-core-c-lf.amemv.com/aweme/v1/aweme/post/?source=0&user_avatar_shrink=") || oSession.fullUrl.Contains("api5-core-c-lf.amemv.com/aweme/v1/user/profile/other/?sec_user_id=") || oSession.fullUrl.Contains("api3.ksapisrv.com/rest/n/user/profile/v2?mod=") || oSession.fullUrl.Contains("api3.ksapisrv.com/rest/n/feed/profile2?mod=")|| oSession.fullUrl.Contains("r.inews.qq.com/verticalSearch?chlid=_qqnews_custom_search_qiehao")|| oSession.fullUrl.Contains("live.kuaishou.com/playback/") || oSession.fullUrl.Contains("vod.a.yximgs.com/livedvr/flv2ts/gifshow/kwai_actL_ksle_") && oSession.fullUrl.Contains("m3u8?") || oSession.fullUrl.Contains("api.weibo.cn/2/cardlist?networktype=wifi&uicode=10000198&moduleID=708&wb_version=3357&lcardid=2310930026_1_%20_") ) { var fso; var file; var filename=""; //快手账号数据 if (oSession.fullUrl.Contains("live.kuaishou.com/playback/")) { //采集快手直播链接 filename = "D:\\fidder_data\\kuaishou_user.txt" fso = new ActiveXObject("Scripting.FileSystemObject"); //文件保存路径,可自定义 file = fso.OpenTextFile(filename,8 ,true); file.writeLine(oSession.fullUrl); file.close(); } else if (oSession.fullUrl.Contains("vod.a.yximgs.com/livedvr/flv2ts/gifshow/kwai_actL_ksle_") && oSession.fullUrl.Contains("m3u8?")) {//采集快手直播链接m3u8链接,及获取所有的ts文件链接 filename = "D:\\fidder_data\\kuaishou_user.txt" fso = new ActiveXObject("Scripting.FileSystemObject"); //文件保存路径,可自定义 file = fso.OpenTextFile(filename,8 ,true); //file.writeLine(oSession.ResponseHeaders); file.writeLine(oSession.fullUrl); var txt = oSession.GetResponseBodyAsString(); file.writeLine(txt); //file.writeLine("\n"); //var txt = oSession.GetResponseBodyAsString() //var startindex =txt.IndexOf('m3u8Url')+9; //var endindex = txt.IndexOf('"__typename":"PlaybackProduct"'); //var m3u8url=txt.Substring(startindex,endindex-startindex); //m3u8url = m3u8url.Replace('"','').Replace(',','') //file.writeLine(m3u8url); file.writeLine("\n"); file.close(); } else { //抖音账号数据 if (oSession.fullUrl.Contains("api5-core-c-lf.amemv.com/aweme/v1/user/profile/other/?sec_user_id=")) { filename = "D:\\fidder_data\\douyin_user.txt" } //抖音账号内容数据 if (oSession.fullUrl.Contains("api5-core-c-lf.amemv.com/aweme/v1/aweme/post/?source=0&user_avatar_shrink=")) { //filename = "D:\\fidder_data\\douyin_content.txt" var startindex=oSession.fullUrl.IndexOf('sec_user_id=')+12; var endindex=oSession.fullUrl.IndexOf('&count=20'); if (endindex>startindex) { var user_id=oSession.fullUrl.Substring(startindex,endindex-startindex); filename = "D:\\fidder_data\\douyin_"+user_id+".txt" } } //腾讯新闻账号查找 if (oSession.fullUrl.Contains("r.inews.qq.com/verticalSearch?chlid=_qqnews_custom_search_qiehao")) { filename = "D:\\fidder_data\\tencent_news_user.txt" } //快手账号内容数据 if (oSession.fullUrl.Contains("api3.ksapisrv.com/rest/n/feed/profile2?mod=")) { filename = "D:\\fidder_data\\kuaishou_content.txt" //var startindex=oSession.fullUrl.IndexOf('sec_user_id=')+12; //var endindex=oSession.fullUrl.IndexOf('&count=20'); //if (endindex>startindex) //{ //var user_id=oSession.fullUrl.Substring(startindex,endindex-startindex); //filename = "D:\\fidder_data\\douyin_"+user_id+".txt" //} } //微博内容数据 if (oSession.fullUrl.Contains("api.weibo.cn/2/cardlist?networktype=wifi&uicode=10000198&moduleID=708&wb_version=3357&lcardid=2310930026_1_%20_")) { var startindex=oSession.fullUrl.IndexOf('2310930026_1_%20_')+17; var endindex=oSession.fullUrl.IndexOf('&c=android&i'); if (endindex>startindex) { var user_id=oSession.fullUrl.Substring(startindex,endindex-startindex); filename = "D:\\fidder_data\\weibo_"+user_id+".txt" } } if (filename!="") { fso = new ActiveXObject("Scripting.FileSystemObject"); //文件保存路径,可自定义 file = fso.OpenTextFile(filename,8 ,true, true); //file.writeLine("Response code: " + oSession.responseCode); var txt = oSession.GetResponseBodyAsString() //var txtjson = JSON.parse(txt); //var flag= txtjson.message; //file.writeLine(flag); file.writeLine(txt); file.writeLine("\n"); file.close(); } } } //if (oSession.fullUrl.Contains("user/profile/homepage/v7/?user_id=") || oSession.fullUrl.Contains("api/feed/profile/v1/?category=profile_article") || oSession.fullUrl.Contains("api/feed/profile/v1/?category=profile_video") || oSession.fullUrl.Contains("api/feed/profile/v1/?category=profile_live")) //{ //oSession.utilDecodeResponse();//消除保存的请求可能存在乱码的情况 //if (oSession.fullUrl.Contains("user/profile/homepage/v7/?user_id=")) //{ //var startindex=oSession.fullUrl.IndexOf('user_id=')+8; //var endindex=oSession.fullUrl.IndexOf('&iid='); //home_user_id=oSession.fullUrl.Substring(startindex,endindex-startindex); //} //if ( oSession.fullUrl.Contains("api/feed/profile/v1/?category=profile_article") || oSession.fullUrl.Contains("api/feed/profile/v1/?category=profile_video") || oSession.fullUrl.Contains("api/feed/profile/v1/?category=profile_live")) //} }
标签:Fiddler,Script,Contains,oSession,user,var,txt,fullUrl 来源: https://www.cnblogs.com/shaosks/p/FiddlerScriptEditor.html