什么是爬虫?——从技术原理到现实应用的全面解析 IV
十七、移动端数据抓取技术
17.1 使用mitmproxy拦截APP数据
# mitmproxy脚本:save_data.py
import json
from mitmproxy import http
class AppDataCapture:
def __init__(self):
self.data_file = open("app_data.jsonl", "a")
def response(self, flow: http.HTTPFlow):
# 过滤目标API
if "api.mobile-app.com/data" in flow.request.url:
data = json.loads(flow.response.text)
# 解密加密数据(示例:AES解密)
decrypted = self._decrypt_payload(data['encrypted'])
# 保存结构化数据
self.data_file.write(jso