Giter VIP home page Giter VIP logo

mitmmock's Introduction

项目介绍

本项目是一个基于 Mitmproxy 的脚本,通过拦截网络请求,直接使用本地数据实现接口 mock。

使用方法

配置信息

mock 接口的 host 与 其开启状态配置

{
    "mockConfig": [
        {
            "host": "www.example.com",
            "enable": true,
            "dir":"www.example.com"
        }
    ]
}

mock 数据放置

在 datas 目录下建一个 host 对应的目录 www.example.com,然后根据需要 mock 接口的 path 建相应的目录与文件。以下面的目录结构为例,实际 mock 的接口是 http://www.example.com/hellohttp://www.example.com/test/aa。

datas
└── www.example.com
    ├── hello
    └── test
        └── aa

mitmproxy 加载脚本

mitmproxy 安装

# 需要在本项目根目录下执行
mitmproxy -p [port] --listen-host [ip] -s mock.py

手机设置

手机和电脑连接到同一网络下,将手机的代理配置为电脑。

接下来就可以正常使用了。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.