Fiddler 配置 配置代理 : Tools -> Options
一、Fiddler添加查看请求类型列 菜单 Rules > Customize Rules
在CustomRules.js里找到static function Main()添加如下一段脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // The Main() function runs everytime your FiddlerScript compiles static function Main() { var today: Date = new Date(); FiddlerObject.StatusText = " CustomRules.js was loaded at: " + today; // Uncomment to add a "Server" column containing the response "Server" header, if present // UI.lvSessions.AddBoundColumn("Server", 50, "@response.server"); // 增加菜单 Method FiddlerObject.UI.lvSessions.AddBoundColumn("Method",60,getHTTPMethod ); // Uncomment to add a global hotkey (Win+G) that invokes the ExecAction method below... // UI.RegisterCustomHotkey(HotkeyModifiers.Windows, Keys.G, "screenshot"); } //获取Method static function getHTTPMethod(oS: Session){ if (null != oS.oRequest) return oS.oRequest.headers.HTTPMethod; else return String.Empty; }
二、Filters的使用
三、请求重放
三、请求转发 场景:将请求转发到本地
from: regex:(?inx)^https://172.16.103.12/drama-api/(?<name>.+)$
to: http://192.168.5.203:8080/drama-api/${name}
四、请求拦截与修改 场景:需要在请求发起前作出修改与放行
1 2 3 4 Rules -> Automatic Breakpoints 可以选择 - Before Request - After Response
Filder进阶教程 示例一:录入脚本获取数据,写入文件
定位到方法:OnBeforeResponse
使用Fildder代理访问:https://www.douyin.com/channel/300203
正常浏览
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 static function OnBeforeResponse (oSession: Session ) { if (m_Hide304s && oSession.responseCode == 304 ) { oSession["ui-hide" ] = "true" ; } if (oSession.fullUrl .Contains ("/aweme/v1/web/channel/feed/" )){ var path = "D:\\douyin\\" try { oSession.utilDecodeResponse (); var body = oSession.GetResponseBodyAsString (); var responseJSON = Fiddler .WebFormats .JSON .JsonDecode (body); FiddlerObject .log ("=======================这一页的抖音视频信息=====================" ) if ((responseJSON.JSONObject =='System.Collections.ArrayList' || responseJSON.JSONObject =='System.Collections.Hashtable' )&&body!='[]' &&body!='{}' ){ for (var list in responseJSON.JSONObject ["aweme_list" ]){ var zuozhe = list["author" ]["nickname" ] var dzs = list["statistics" ]["digg_count" ] var title = list["desc" ] var videoUrl = list["video" ]["play_addr" ]["url_list" ][1 ] FiddlerObject .log ("视频标题:" + title + "|作者:" + zuozhe + "|点赞数:" + dzs) FiddlerObject .log ("视频下载地址:" + videoUrl) saveTextToLocal (path, "视频标题:" + title + "|作者:" + zuozhe + "|点赞数:" + dzs) saveTextToLocal (path, "视频下载地址:" + videoUrl) } } FiddlerObject .log ("=======================这一页的抖音视频信息=====================" ) }catch (e){ FiddlerObject .log ("代码出现错误,错误原因:" +e) } } } static function saveTextToLocal (textpath, body ) { var fso; var file; try { if (!System .IO .Directory .Exists (textpath)) { System .IO .Directory .CreateDirectory (textpath); } fso = new ActiveXObject ("Scripting.FileSystemObject" ); file = fso.OpenTextFile (textpath + "douyin.txt" , 8 , true , true ); file.writeLine (body); file.close (); return true ; } catch (e) { if (file != null ) { file.close (); } FiddlerObject .log ("保存文件出错,错误原因:" + e); return false ; } }
效果:
为正常使用来必力评论功能请激活JavaScript