爬蟲(chóng)工具—whistle安裝與修改瀏覽器接口返回值

一 whistle安裝(mac)

1 安裝node.js

whistle是基于node實(shí)現(xiàn)的,node.js官網(wǎng):http://nodejs.cn/

下載并按照提示安裝

2 whistle安裝

1) 終端使用npm命令安裝whistle

$ npm install -g whistle

2) 終端啟動(dòng)whistle

aaadeMacBook-Pro:~ root# w2 start --init
[i] whistle@2.9.22 started
[i] 1. use your device to visit the following URL list, gets the IP of the URL you can access:
       http://127.0.0.1:8899/
       http://172.20.20.131:8899/
       http://192.168.72.115:8899/
       Note: If all the above URLs are unable to access, check the firewall settings
             For help see https://github.com/avwo/whistle
[i] 2. set the HTTP proxy on your device with the above IP & PORT(8899)
[i] 3. use Chrome to visit http://local.whistlejs.com/ to get started
Setting global proxy (127.0.0.1:8899) successful.
security: SecKeychainCopyDefault: A default keychain could not be found.

添加「--init」會(huì)初始化mac的全局代理設(shè)置,關(guān)閉whislte后需要把下圖的兩個(gè)??去掉才能正常聯(lián)網(wǎng)


mac網(wǎng)絡(luò)偏好設(shè)置

3) whistle其他操作

關(guān)閉whistle

$ w2 stop

重啟whistle

$ w2 restart

whistle幫助

$ w2 help

3 打開(kāi)whistle后臺(tái)管理頁(yè)面

在瀏覽器輸入127.1:8899進(jìn)入whistle后臺(tái)管理頁(yè)面

二 https證書(shū)安裝

1 證書(shū)下載

點(diǎn)擊whistle頁(yè)面菜單中的HTTPS,點(diǎn)擊二維碼,即可下載證書(shū)。


2 證書(shū)安裝

https://jingyan.baidu.com/article/5225f26ba6dbfce6fb090856.html

三 修改接口返回值

需要先找到需要修改返回值的接口

1 獲取返回結(jié)果模板

打開(kāi)瀏覽器訪問(wèn)頁(yè)面,在控制臺(tái)中找到需要修改返回值的接口,copy該接口的返回值


2 設(shè)置返回結(jié)果

打開(kāi)whistle管理頁(yè)面,在value中新建一個(gè)json文件,將復(fù)制的內(nèi)容粘貼到文件中,修改參數(shù)為自己需要的返回結(jié)果


修改后,要點(diǎn)擊「save」才會(huì)保存生效

3 在rules中設(shè)置規(guī)則

進(jìn)入Rules-->default中設(shè)置規(guī)則,內(nèi)容格式:

#該接口請(qǐng)求的URL file://{values中存放該接口返回的文件名+文件后綴}
http://127.0.0.1:8080/test file://{list.json}

點(diǎn)擊「save」即可生效

4 重新載入頁(yè)面,查看接口返回結(jié)果

參考:
http://www.itdecent.cn/p/17c48959be44
https://www.cnblogs.com/lv-lxz/p/16030338.html
https://jingyan.baidu.com/article/5225f26ba6dbfce6fb090856.html
https://www.cnblogs.com/lv-lxz/p/16030338.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容