以前曾经用过mitmproxy做中间人代理来做淘宝登陆,但是代码一下子找不到了,于是百度了使用方法,发现完全不如当初自己用的那个简单。各种命令行什么的。所以在这里分享一下曾经找到的最简单的使用方法,纯python脚本,不需要任何命令行操作。
业务逻辑在response;里修改。
貌似现在淘宝如果用selenium就算修改了特征码也过不了滑动验证码了。不知道兄弟们有没有别的方法。我是打算换工具了。手机端hook是一条路,直接用浏览器也是一个解法
# -*- coding: utf-8 -*-
# @Time : 2019/10/31 16:21
# @Author : meng_zhihao
# @Email : 312141830@qq.com
# @File : test.py
from mitmproxy import proxy, options
from mitmproxy.tools.dump import DumpMaster
from mitmproxy.script import concurrent
from mitmproxy import flowfilter
from mitmproxy import ctx, http
import time
class AddHeader:
@concurrent
def request(self, flow):
print(flow.request.pretty_host)
# print("handle request: %s%s" % (flow.request.host, flow.request.path))
# time.sleep(1)
# print("start request: %s%s" % (flow.request.host, flow.request.path))
@concurrent
def response