Use Charles Proxy for Mac to crawl the mobile app's network package

Source: Internet
Author: User

Before doing Web projects, often use Fiddler (under Windows), Charles Proxy (under the Mac) to grab the package, debugging something, now engaged in Android app development, sometimes need to analyze the mobile app network requests, including parameters, return values and so on. There are a few steps that you can continue to use with Charles Proxy to catch a network packet from the Android app on your Mac:

1, ensure that the phone and Mac are connected to the same wireless LAN

2, open the Charles Proxy on the Mac, menu bar operation: Proxy→proxy Setting, check the port, generally keep the default, HTTP Proxy port is 8888

3. Check your Mac's current IP address, then use it as proxy IP for your phone:


4, edit the phone's WiFi connection, long press the current connected WiFi network:


5. Select "Modify Network" to enter the editing mode of the network connection (select "Show Advanced Options") and Save:


6, at this time can be in the mobile phone app to do a random operation, such as the Tieba client one-click Check-in:


7, observe the grasp of the package on Charles Proxy:


The captured packet display is very friendly and can be edited for requests that have already been sent, then sent again (mock request and parse result).

The above is a general use of the process, about this Charles Proxy, do not introduce too much, windows, you can use Fiddler (2/4), the default port is also 8888, of course, you can easily change.

In addition, a download package with Charles Proxy for MAC (with serial number: for lazy people): charles-proxy-for-mac-3.8.1


Agent Tools Charles Uses



One. Tracking HTTPS

1. Download the official Certificate Ssl.zip certificate, unzip it into *.CRT

2. You can download and install CRT files by email or by posting to your server and then using your phone.

3.charles set PROXY-->SSL, check the Enable SSL proxying, click "Add" below, add the domain name + port number you need to verify and tick. For example: *.my.com, mobileapi.myserver.com

4. The phone set the corresponding proxy IP, this time you can see the contents of the HTTPS request in Charles

PS: in step 3 if you tick, but your device does not install a certificate, if you go to the agent will request failure. Unchecked, you can request success, but you cannot see the content.

Encounter mthd= "Connect", request See "SSL proxying not enabled for this host:enable in Proxy Settings, SSL Locations" error, then the 3rd step does not have the domain The name is set well.


Two. Powerful mapping function

In a nutshell, you can debug a file that is remotely proxied to a local file.

1. Open My CSDN Blog home page, and then you can see the loaded pages and related resources in Charles, find a JS file to do the agent,


2, create a local file 1.txt, I will realtime.js response copy down, and at the beginning to add their own JS statement "alert (123)"

3. Select "Map Local." and set the note that I set the "*" in paramter, because in many cases the interface may have random strings, and of course URLs can also use wildcards to match


4. Click OK to refresh the page again. The page pops up alert with the content: "123". and in the "Notes" tab will tell you "Mapped to local file:/users/apple/desktop/1.txt", indicating success



5. If you want to delete the Map address you have set, you can tools-->map the Local ... Management, add or delete, very convenient.


Three. Speed simulation

Proxy-->throttling Setting, can simulate the network speed in various situations, so as to see the app usage in low speed situation

Partial set meaning, Bandwidth (bandwidth), utilistation (utilization percentage), round-trip (round-trip delay), MTU (bytes)


Four. Breakpoint function

An app interface needs to call the interface and return data to draw the interface. We can manipulate the requested data or the returned data by using the breakpoint function to achieve the simulated effect. Let's see what we can do.

1. Similar to mapping, we can select "breakpoints" to the right of the interface, so that the interface is added to the breakpoint state

2. Need to further modify the properties of the breakpoint, can be added in the menu bar "Proxy"--"breakpoints" to add delete or modify, configuration and mapping similar, you can also use wildcards to operate, And you can choose whether this breakpoint is on request or response, or both.

3. This time again refresh the interface, will jump directly to the breakpoint template, this time you can modify the request or response in the corresponding state, and then click the button "Execute" below.



Five. Repeat the Send

This seems to have little to do with the front end, which can test robustness on the interface, and right-click on a request, then "repeat" or "repeat Advance", which can set the number and interval of cyclic calls


Six. Support Chinese display

Open Charles.app, locate Info.plist, and then add the parameters-dfile.encoding=utf-8




Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Use Charles Proxy for Mac to crawl the mobile app's network package

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.