from mitmproxy import http
import json
# mitmdump -s proxy.py
# 指定要捕获的接口
target_url = "https://csdn.com"
def request(flow: http.HTTPFlow) -> None:
# 检查请求的URL是否匹配目标接口
if flow.request.pretty_url.startswith(target_url):
print(f"Captured request to {target_url}")
# print(f"Request headers: {flow.request.headers}")
# print(f"Request body: {flow.request.content}")
def response(flow: http.HTTPFlow) -> None:
# 检查响应的URL是否匹配目标接口
if flow.request.pretty_url.startswith(target_url):
print(f"Captured response from {target_url}")
# print(f"Response status code: {flow.response.status_code}")
# print(f"Response headers: {flow.response.headers}")
# print(f"Response body: {flow.response.content}")
jsondata=json.loads(flow.response.content)
for k,v in enumerate(jsondata["data"]["list"]):
print(v["id"])
使用Python抓取抖音直播间数据的简易指南【第152篇—抓取数据】
2024-07-18 10:38:05 33 阅读