接口 mock 实战 [二]作业



代码路径:https://github.com/zhangguili123/pytestDemo/tree/master/testproxy
张贵丽提交作业

https://github.com/XFbeibei/HogwartsLagoutesting/tree/master/http

from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    # pretty_url takes the "Host" header of the request into account, which
    # is useful in transparent mode where we usually only have the IP otherwise.

    if "quote.json" in flow.request.pretty_url and "x=" in flow.request.pretty_url:
        with open("D:/ProgramWorkspace/TestingDemo/test_mitmproxy/stock2.json",encoding="utf-8") as f:
            flow.response = http.HTTPResponse.make(
                200,  # (optional) status code
                f.read(),  # (optional) content
                {"Content-Type": "application/json"}  # (optional) headers

xueqiu-stock2



王刚作业:

胡玉琦的作业

https://github.com/huyq119/mitmproxymock.git

接口mock实战第二次作业
https://github.com/feillusion/hogwarts/tree/main/homework/mock

另外有个疑问:为什么股票开盘之后,这个页面刷新后就不是从股价和涨跌幅度就不是从maplocal获取数据呢?此时名称却还是从maplocal获取的

QQ图片20210319101700 QQ图片20210319101810

补作业

吕川作业:




图片