whistle官网下载及使用:
http://wproxy.org/whistle/
一、功能
![](https://i-blog.csdnimg.cn/blog_migrate/4e93206d9099f85f1d28745729c2bed4.png)
二、安装启动whistle
1、Windows和Mac系统,访问https://nodejs.org/,安装LTS版本的Node,默认安装即可
2、安装完成Node后,执行命令,查看当前node版本
C:\Users\zhaoyajun18>
node -v
(如正常输出Node的版本号,表示Node安装成功(Windows系统需重新打开cmd))
3、安装whistle
C:\Users\zhaoyajun18>
npm install -g whistle
4、相关执行命令
C:\Users\zhaoyajun18>
w2 help
5、启动whistle
C:\Users\zhaoyajun18>
w2 start
6、停止whistle
C:\Users\zhaoyajun18>
w2 stop
7、重启whistle
C:\Users\zhaoyajun18>
w2 restart
8、开发模式启动
C:\Users\zhaoyajun18>
w2 run
这种启动方式可以看到插件输出的
console
日志,且会自动加载当前目录的所有插件
这种启动方式无法用w2 stop去终止,也无法用w2 restart重启
三、防火墙配置
![](https://i-blog.csdnimg.cn/blog_migrate/b33a4c97d31236e8a0c31a0e5630cb99.png)
四、配置代理
2、
浏览器选择whistle作为代理
![](https://i-blog.csdnimg.cn/blog_migrate/10185dba214de7a14ac906d8d6d3bfac.png)
五、PC端抓包
1、启动whistle:win+R——>w2 start
![](https://i-blog.csdnimg.cn/blog_migrate/9032684c9c307423fe1e8b9f301cee67.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2db80e165bcb84131394960489a50bcd.png)
3、打开SwitchOmega选择配置好的“whistle”
![](https://i-blog.csdnimg.cn/blog_migrate/f5138ce1d5f966fe8003ef6a84175ec6.png)
4、安装证书
![](https://i-blog.csdnimg.cn/blog_migrate/ed5c9ef8cba9141a81fb0b2c50f76f33.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1554e4f7e000202ebbcc3c9b2386487f.png)
5、查看抓到的包
![](https://i-blog.csdnimg.cn/blog_migrate/c195a9bd9add17b98f94b8563fb49f8b.png)
![](https://i-blog.csdnimg.cn/blog_migrate/052c6ae1eaac7a527efd7d2eea2a72f5.png)
6、对于抓到的包主要关注以下信息
![](https://i-blog.csdnimg.cn/blog_migrate/388a1a03e4e57b70f06d75ce6bbcf9eb.png)
![](https://i-blog.csdnimg.cn/blog_migrate/db5dac5dfa89b912ef279aaca12d8bef.png)
![](https://i-blog.csdnimg.cn/blog_migrate/34569c9cce62c15dd0f41c4a9a1892e5.png)
Access-Control-Request-Method:post
:请求的方法
六、移动端抓包
1、启动whistle:win+R——>w2 start
![](https://i-blog.csdnimg.cn/blog_migrate/ef29428a13524e63a4f2985c9bdf9cec.png)
3、打开SwitchOmega选择配置好的“whistle”
![](https://i-blog.csdnimg.cn/blog_migrate/7110c8f369d9ff45cc87ae80df13ba04.png)
4、电脑开启热点
![](https://i-blog.csdnimg.cn/blog_migrate/e69c450da56f8a816e64dc0e204cdc76.png)
5、查看内网ip
![](https://i-blog.csdnimg.cn/blog_migrate/cfa1bbca8007abdbfb6b3d73bc58c906.png)
![](https://i-blog.csdnimg.cn/blog_migrate/f755994f59bf32b0ca71ebccc16c8e14.png)
6、手机连接电脑热点——配置代理(代理的ip为电脑ip,端口为whistle启动端口)
![](https://i-blog.csdnimg.cn/blog_migrate/14110583b3addbe7031d0f3f212474cd.png)
7、在手机浏览器输入http://rootca.pro/下载证书
8、查看抓到的包
![](https://i-blog.csdnimg.cn/blog_migrate/29fa95ce6ea9ed20a7616fad7f477bba.png)
七、前端mock数据
1、打开一个html页面,找到对应的 html文件,下载至本地进行修改
首先将代码复制到Visual Studio Code,保存为.josn格式,右击选择Format Document做格式调整,改完需要修改的数据,保存,修改文件类型为index.html
![](https://i-blog.csdnimg.cn/blog_migrate/65061221352ab376ac270e39b8567447.png)
![](https://i-blog.csdnimg.cn/blog_migrate/def2aca3a14810f5ea6e8a4745d0d219.png)
2、在【Rules】写入对应的请求链接(.html),以及本地存放index.html的路径
![](https://i-blog.csdnimg.cn/blog_migrate/823ea351d9d8bece8261c2500f39844c.png)
可加file://,可不加
八、接口mock数据
1、在【values】写入接口返回内容.josn
![](https://i-blog.csdnimg.cn/blog_migrate/9f914be9cd7ab948b020b4aeffe894de.png)
2、在【Rules】写mock的接口,格式:
URL file://{filename}
![](https://i-blog.csdnimg.cn/blog_migrate/16c7feae6ca9e4bf52af76d23bb1b677.png)
3、
配
置完成——抓到请求为mock的接口——whistle直接将文件(.json)内容作为response返回给请求端
![](https://i-blog.csdnimg.cn/blog_migrate/f5652a5ffe3f97905a8299e34a0c3927.png)
九、补充 Cookli缓存信息
![](https://i-blog.csdnimg.cn/blog_migrate/4f50e8d14097e080424e61c238b7df92.png)
![](https://i-blog.csdnimg.cn/blog_migrate/2a4857c83dbfdddeb67ac96df7215ad0.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3055806f05e88d82b3db4865e344c5fb.png)