1. 程式人生 > >MAC上的抓包工具charles的安裝與使用

MAC上的抓包工具charles的安裝與使用

Charles的更多應用

1、過濾網路請求

有時候我們只想抓取某個主機的網路請求,我們可以設定過濾網路,在Proxy選單中的Recording Setting中,我們選擇include標籤,可以在裡面新增一個白名單,這樣Charles就只擷取在這個主機下的請求: 
這裡寫圖片描述

如果彈框沒有出現,將charles切換為小視窗

2、模擬限速網路

很多時候,我們需要測試在網路不佳時應用請求的相關資料,我們可以模擬設定限速網路,在Proxy選單中的Throttle Settings中將,Enable Throttling勾選,並可以在下面進行網路設定,only for selected host可以設定一個指定的主機訪問進行限制網路。 
這裡寫圖片描述

3、修改網路資訊,多次請求

在測試介面時,有時候我們需要反覆進行不同引數的介面請求,Charles也支援我們進行請求引數的修改和多次請求,在請求上點選右鍵,現則edit: 
這裡寫圖片描述
其中的引數,請求型別等我們都可以修改,之後點選execute進行重新請求 
這裡寫圖片描述

批量請求選擇repeat advanced....

這裡寫圖片描述

<code class="hljs cs has-numbering" style="display: block; padding: 0px; background-color: transparent; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background-position: initial initial; background-repeat: initial initial;">iterations:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">10</span>   <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//請求次數</span>
concurrency:<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>   <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//請求的併發數</span>
show results <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">in</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">new</span> session <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//新建一個session視窗</span>
delays  <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">//請求延遲</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; background-color: rgb(238, 238, 238); top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>

六、Charles 網路請求重定向

tools->map remote 
這裡寫圖片描述