Backend Development 6 min read

Capturing App Traffic with Stream and Parsing HAR Files Using Python

This guide explains how to quickly capture network traffic from a mobile app using the Stream proxy, export the data as a HAR file, and then decode and parse the compressed responses with a short Python script to extract the desired JSON information.

Sohu Tech Products
Sohu Tech Products
Sohu Tech Products
Capturing App Traffic with Stream and Parsing HAR Files Using Python

When you need to extract specific data from a mobile app or mini‑program without writing a full‑featured crawler, a lightweight approach using a proxy and a few lines of Python can automate the process.

The tutorial starts by installing the Stream app on iOS, setting up its root certificate, and enabling the capture function. All traffic from the target app (in the example, the "Jump" app for the game "The Legend of Zelda: Tears of the Kingdom") is routed through Stream.

After scrolling through the armor list in the Jump app, you stop the capture, open the capture history, and filter the requests by domain to isolate those sent by the Jump app. The filtered requests are then selected and exported as a HAR file.

On a computer, the exported HAR file is processed with a short Python script. The script uses the haralyzer library to read the HAR, extracts the text field from each response, decodes the Base64‑encoded string, and decompresses it with brotli to obtain readable JSON data.

import json
import brotli
import base64
from haralyzer import HarParser

with open('/Users/kingname/Downloads/Stream-2023-07-06 22:08:44.har') as f:
    har_parser = HarParser(json.loads(f.read()))

data = har_parser.har_data
entries = data['entries']
for entry in entries:
    text = entry['response']['content']['text']
    content = brotli.decompress(base64.b64decode(text)).decode()
    info = json.loads(content)
    print(info)

The script prints the JSON objects containing the armor data, which can then be further processed as needed. The guide notes that for most HAR files the response text is already readable, but the Jump app compresses its payload with Brotli, requiring the extra decompression step.

Finally, the article summarizes the workflow: install Stream, enable capture, browse the target app, stop capture, filter and export the HAR, and parse it with Python. Once familiar, the whole process can be completed in under three minutes.

ProxypythonData ExtractionHAR parsingnetwork captureStream app
Sohu Tech Products
Written by

Sohu Tech Products

A knowledge-sharing platform for Sohu's technology products. As a leading Chinese internet brand with media, video, search, and gaming services and over 700 million users, Sohu continuously drives tech innovation and practice. We’ll share practical insights and tech news here.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.