python 结合mitmproxy 抓取指定接口数据

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"])

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-18 10:38:05       66 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-18 10:38:05       70 阅读
  3. 在Django里面运行非项目文件

    2024-07-18 10:38:05       57 阅读
  4. Python语言-面向对象

    2024-07-18 10:38:05       68 阅读

热门阅读

  1. mybatis-plus仿 JPA的 GenerationType.TABLE 实现

    2024-07-18 10:38:05       22 阅读
  2. C语言 反转链表

    2024-07-18 10:38:05       22 阅读
  3. wsl的坑

    2024-07-18 10:38:05       20 阅读
  4. 在Ubuntu 18.04上安装和保护Redis的方法

    2024-07-18 10:38:05       20 阅读
  5. 今日安装了一下Eclipse,配置了SVN

    2024-07-18 10:38:05       19 阅读
  6. vue 手机右滑返回

    2024-07-18 10:38:05       21 阅读
  7. 数据标准化与归一化:深入理解及应用

    2024-07-18 10:38:05       21 阅读
  8. PCDN技术如何优化网络延迟?

    2024-07-18 10:38:05       22 阅读
  9. Html_Css问答集(10)

    2024-07-18 10:38:05       19 阅读
  10. Python情感分析、分词、关键词提取、相似度计算

    2024-07-18 10:38:05       19 阅读