超好用的代理、调试工具——Whistle(使用)

464 阅读1分钟

Whistle官方文档

1、whistle界面功能详解

2、抓包

image.png

image.png

3、Mock:接口返回的状态码

https://stock.xueqiu.com/v5/stock/hot_stock/list.json?size=8&_type=10&type=10 replaceStatus://500

image.png

4、Mock:添加接口返回的字段

  • 简单字段直接Merge

https://stock.xueqiu.com/v5/stock/hot_stock/list.json?size=8&_type=10&type=10 resMerge://(resMerge={}&resMerge_description="这是补充字段Mock")

image.png

  • 复杂数据values配置json文件,Merge-Json文件

image.png

5、Mock:覆盖接口返回的数据

建议使用配置values中json文件,覆盖mock数据 https://stock.xueqiu.com/v5/stock/hot_stock/list.json?size=8&_type=10&type=10 resBody://{whistle_test.json}

image.png

image.png

6、Mock:设置为弱网络模式,延迟3000ms

https://stock.xueqiu.com/v5/stock/hot_stock/list.json?size=8&_type=10&type=10 resDelay://3000

image.png

image.png

7、配置响应头:解决跨域问题

https://stock.xueqiu.com/v5/stock/hot_stock/list.json?size=8&_type=10&type=10 resHeaders://{whistle_test.json}

image.png

image.png

image.png

8、代理:配置代理规则,可以在设置中多选且按配置规则顺序匹配代理;

image.png

image.png

9、修改请求头、响应头的cookie信息

10、插入js文件:可以在不修改页面代码的情况下,通过 whistle 往页面插入 js

image.png

image.png

11、安装inspect 使用vConsole.log调试

npm i -g whistle.inspect

https://www.baidu.com whistle.inspect://

image.png

12、路由重定向:将雪球“热股榜”页面,重定向到“热帖页面”

https://xueqiu.com/S/SZ002855 redirect://https://xueqiu.com/8244195263/262002276

image.png

image.png

image.png

13、其他功能:

  1. url生成二维码
  2. Json格式转化
  3. 图片转成Base64编码

image.png