mitmproxy抓包 | Python疑难测试场景mock实战(四)

王大力测试进阶之路

共 26709字,需浏览 54分钟

 ·

2021-12-05 08:44

往期经典文章回顾:

抓包工具mitmproxy环境配置使用(一)

抓包工具mitmproxy | mitmweb基本用法(二)

mitmproxy抓包 | Python实时生成接口自动化用例

mitmproxy抓包 | Python实时生成接口自动化用例(三)


在实际工作中,经常会遇到前端模块开发完了,后端还没开发完,测试闲的没事干,导致测试介入延迟,为了解决此问题,我们可以采用mitmproxy代理抓包进行mock服务测试,根据接口文档mock不同的响应数据,对前端功能进行测试,提前介入测试,暴露问题,节省项目成本。


 还有一些疑难测试场景,很难手动模拟出来,简单介绍一种,例如:已打卡,button置灰无法再次打卡测试重复提交,小A说:可以快速连点,如果前端做了防重点,还是很难连点出来进行测试的;小B说:可修改数据库打卡状态,这样只能说明他今天没打卡,还可以进行正常打卡的,未达到测试重复提交测试效果;小C说:可以通过接口重复请求进行测试,这样是可以的,但是只是针对后端重复提交进行了测试,还是未达到前端测试的效果;小D说:可以通过模拟网络延迟,这个应该是可以的,因为当你点击签到时,请求发出去了,响应还没有回来,打卡button还未更新,仍显示的亮起可打卡,这时,可以再次发起第2次打卡,测试重复提交。


借助mitmproxy代理抓包工具的mock功能还是很方便,结合简单的python脚本匹配要mock的接口地址,替换成想要设置的响应数据,每次APP

发起请求,会经过mitmproxy代理抓包工具,得到设置好的响应数据,前端对应展示出我们想要的测试场景。


我们以得物APP-打卡话题列表-今天只晒鞋-打卡,案例实战一下,测试场景:打卡成功,再次打卡



未打卡时,打卡话题页面,今天只晒鞋,立即打卡显示亮起可点击

ffd61ced24e66e347f30eed35cb61da8.webp

未打卡时,打卡话题列表接口信息


https://m.dewu.com/sns/v1/tag/clockin-topic-list?newSign=338e7a221b66936aa313763a5c139a42
appId: duappbrand: ApplecookieToken: d41d8cd9|1573201658|1638408681|68e26bc5b040d083emu: 0isProxy: 1isRoot: 0lastId: limit: 20loginToken: 44462107|1573201658|4bed211ae9d2d5a8mode: 0platform: iPhoneshumeiid: 20210918092735f1e54bce67bb69d503b7fb355c4690cf01d77ce3f35e2132sign: a2a9aa440b638aafd8b4ff62671231edtimestamp: 1638409137400token: JLIjsdLjfsdII%3D%7CMTQxODg3MDczNA%3D%3D%7C07aaal32795abdeff41cc9633329932195userId: 1573201658uuid: UUID785a82408e934daf9f9240fb286900eav: 4.79.7

{ "data": { "existOfflineClockin": 0, "go": true, "lastId": "", "list": [ { "clockInId": "19", "containsNum": 1971522, "orderBy": "665", "tagDesc": "鞋狗每日打卡!晒晒你的宝贝球鞋\n欢迎分享:球鞋上脚照、入手感受、搭配建议等\n图片、文字符合主题,可获得更多点赞和关注!", "tagId": 295, "tagName": "今天只晒鞋", "thumb": "https://du.hupucdn.com/Fu1T5EEUemk6sW6210x8O5M7-woi", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "47", "containsNum": 1594616, "orderBy": "663", "tagDesc": "OOTD,来分享你的每日穿搭~", "tagId": 9, "tagName": "今天穿什么", "thumb": "https://du.hupucdn.com/FtoOBG0AM6e0MYXcEvxq6Rctcbjs", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "126", "containsNum": 87783, "orderBy": "657", "tagDesc": "欢迎分享各类体育比赛视频,送你上首页推荐!", "tagId": 267, "tagName": "体育精彩视频分享", "thumb": "https://du.hupucdn.com/lghvdJY0hjTdIOHV870o1-l41SHl", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "138", "containsNum": 83280, "orderBy": "655", "tagDesc": "欢迎分享你喜爱的、想推荐的说唱音乐视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 1360, "tagName": "说唱音乐视频分享", "thumb": "https://du.hupucdn.com/Fr1A4aB9BxdLb_RrHZ84WI6Cj8o7", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "140", "containsNum": 68899, "orderBy": "650", "tagDesc": "欢迎分享你喜爱的、想推荐的街舞视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 247, "tagName": "街舞视频分享", "thumb": "https://du.hupucdn.com/FoAfCBfHKIfxvr5pWPjvxvBelfZY", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "25", "containsNum": 293796, "orderBy": "644", "tagDesc": "康康你的自拍照,有机会上首页推荐哦!", "tagId": 310, "tagName": "就是爱自拍", "thumb": "https://du.hupucdn.com/Fn3LjHqtx1mR1TsJhhIuMzklPzC0", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "147", "containsNum": 220616, "orderBy": "643", "tagDesc": "让我康康仙女都在买啥(⊙_⊙)", "tagId": 1595, "tagName": "美妆种草", "thumb": "https://du.hupucdn.com/FpeNLkzEWUeckefHu0gxqFKPqvab", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "83", "containsNum": 1498983, "orderBy": "642", "tagDesc": "那些你最喜欢的壁纸,和大家一起分享吧~", "tagId": 249, "tagName": "每日一张壁纸", "thumb": "https://du.hupucdn.com/Fm5FlcDrKBPvRZr67F-nJKEdaj6r", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "15", "containsNum": 72869, "orderBy": "640", "tagDesc": "不怕车不帅就怕你不发,冲!", "tagId": 16, "tagName": "就想晒个车", "thumb": "https://du.hupucdn.com/FjFXqQEyo6aAh9MrKQb787m-LBxy", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "67", "containsNum": 78132, "orderBy": "638", "tagDesc": "入手了新玩具?快来晒晒吧!有机会上首页推荐哦!", "tagId": 259, "tagName": "晒下新玩具", "thumb": "https://du.hupucdn.com/FnKepVPzANQsDvrTiomW7kWZubIs", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "3", "containsNum": 68547, "orderBy": "636", "tagDesc": "来这里,记录你的坚持与汗水!记得每日来打卡哦!", "tagId": 311, "tagName": "每日运动打卡", "thumb": "https://du.hupucdn.com/FkpHtyz3peiEPM_sB9WpfmGcfpBO", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "139", "containsNum": 27149, "orderBy": "634", "tagDesc": "欢迎分享你喜爱的、想推荐的电音视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 944, "tagName": "电音视频分享", "thumb": "https://du.hupucdn.com/FjoGu5hvULvDfX8obhAh742zsOxi", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "142", "containsNum": 8309, "orderBy": "632", "tagDesc": "板仔集合,秀出你的滑板技能!", "tagId": 1154, "tagName": "我的滑板日常", "thumb": "https://du.hupucdn.com/Ftx6RZSUqR1uHpmzeoZytO7LtXaA", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "9", "containsNum": 2733545, "orderBy": "576", "tagDesc": "每天都要潮出不一样", "tagId": 302, "tagName": "潮流生活打卡", "thumb": "https://du.hupucdn.com/FjTjA377QeYZDf9oyKyykaNi8L3w", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "125", "containsNum": 181923, "orderBy": "574", "tagDesc": "趣味视频、日常生活记录视频、开箱视频....分享送你上首页推荐!\n\n", "tagId": 1263, "tagName": "每日视频打卡", "thumb": "https://du.hupucdn.com/lnFKpWrTBz2N25MdzBU2Yti76vT6", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" } ] }, "env": "cs", "log": null, "msg": "成功", "status": 200, "timestamp": 0.072869062423706}


已打卡时,打卡话题列表,今天只晒鞋,立即打卡显示置灰不可点击

0505c3e58e27c3f9fffade359fad877f.webp

已打卡时,打卡话题列表接口信息:


https://m.dewu.com/sns/v1/tag/clockin-topic-list?newSign=ee05369a4777bee2b6b340a1bba10cfc
appId: duappbrand: ApplecookieToken: d41d8cd9|1573201658|1638408681|68e26bc5b040d083emu: 0isProxy: 1isRoot: 0lastId: limit: 20loginToken: 44462107|1573201658|4bed211ae9d2d5a8mode: 0platform: iPhoneshumeiid: 20210918092735f1e54bce67bb69d503b7fb355c4690cf01d77ce3f35e2132sign: aa6f76720b6f4f7eb8e79c067f369994timestamp: 1638409518296token: JLIjsdLjfsdII%3D%7CMTQxODg3MDczNA%3D%3D%7C07aaal32795abdeff41cc9633329932195userId: 1573201658
{ "data": { "existOfflineClockin": 0, "go": true, "lastId": "", "list": [ { "clockInId": "19", "containsNum": 1971527, "orderBy": "665", "tagDesc": "鞋狗每日打卡!晒晒你的宝贝球鞋\n欢迎分享:球鞋上脚照、入手感受、搭配建议等\n图片、文字符合主题,可获得更多点赞和关注!", "tagId": 295, "tagName": "今天只晒鞋", "thumb": "https://du.hupucdn.com/Fu1T5EEUemk6sW6210x8O5M7-woi", "userContinuousNum": "1", "userHistoryNum": 1, "userJoined": "1", "userRank": "99+", "userTodayJoined": "1" }, { "clockInId": "47", "containsNum": 1594621, "orderBy": "663", "tagDesc": "OOTD,来分享你的每日穿搭~", "tagId": 9, "tagName": "今天穿什么", "thumb": "https://du.hupucdn.com/FtoOBG0AM6e0MYXcEvxq6Rctcbjs", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "126", "containsNum": 87783, "orderBy": "657", "tagDesc": "欢迎分享各类体育比赛视频,送你上首页推荐!", "tagId": 267, "tagName": "体育精彩视频分享", "thumb": "https://du.hupucdn.com/lghvdJY0hjTdIOHV870o1-l41SHl", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "138", "containsNum": 83280, "orderBy": "655", "tagDesc": "欢迎分享你喜爱的、想推荐的说唱音乐视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 1360, "tagName": "说唱音乐视频分享", "thumb": "https://du.hupucdn.com/Fr1A4aB9BxdLb_RrHZ84WI6Cj8o7", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "140", "containsNum": 68899, "orderBy": "650", "tagDesc": "欢迎分享你喜爱的、想推荐的街舞视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 247, "tagName": "街舞视频分享", "thumb": "https://du.hupucdn.com/FoAfCBfHKIfxvr5pWPjvxvBelfZY", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "25", "containsNum": 293797, "orderBy": "644", "tagDesc": "康康你的自拍照,有机会上首页推荐哦!", "tagId": 310, "tagName": "就是爱自拍", "thumb": "https://du.hupucdn.com/Fn3LjHqtx1mR1TsJhhIuMzklPzC0", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "147", "containsNum": 220616, "orderBy": "643", "tagDesc": "让我康康仙女都在买啥(⊙_⊙)", "tagId": 1595, "tagName": "美妆种草", "thumb": "https://du.hupucdn.com/FpeNLkzEWUeckefHu0gxqFKPqvab", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "83", "containsNum": 1498987, "orderBy": "642", "tagDesc": "那些你最喜欢的壁纸,和大家一起分享吧~", "tagId": 249, "tagName": "每日一张壁纸", "thumb": "https://du.hupucdn.com/Fm5FlcDrKBPvRZr67F-nJKEdaj6r", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "15", "containsNum": 72870, "orderBy": "640", "tagDesc": "不怕车不帅就怕你不发,冲!", "tagId": 16, "tagName": "就想晒个车", "thumb": "https://du.hupucdn.com/FjFXqQEyo6aAh9MrKQb787m-LBxy", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "67", "containsNum": 78133, "orderBy": "638", "tagDesc": "入手了新玩具?快来晒晒吧!有机会上首页推荐哦!", "tagId": 259, "tagName": "晒下新玩具", "thumb": "https://du.hupucdn.com/FnKepVPzANQsDvrTiomW7kWZubIs", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "3", "containsNum": 68548, "orderBy": "636", "tagDesc": "来这里,记录你的坚持与汗水!记得每日来打卡哦!", "tagId": 311, "tagName": "每日运动打卡", "thumb": "https://du.hupucdn.com/FkpHtyz3peiEPM_sB9WpfmGcfpBO", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "139", "containsNum": 27149, "orderBy": "634", "tagDesc": "欢迎分享你喜爱的、想推荐的电音视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 944, "tagName": "电音视频分享", "thumb": "https://du.hupucdn.com/FjoGu5hvULvDfX8obhAh742zsOxi", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "142", "containsNum": 8310, "orderBy": "632", "tagDesc": "板仔集合,秀出你的滑板技能!", "tagId": 1154, "tagName": "我的滑板日常", "thumb": "https://du.hupucdn.com/Ftx6RZSUqR1uHpmzeoZytO7LtXaA", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "9", "containsNum": 2733550, "orderBy": "576", "tagDesc": "每天都要潮出不一样", "tagId": 302, "tagName": "潮流生活打卡", "thumb": "https://du.hupucdn.com/FjTjA377QeYZDf9oyKyykaNi8L3w", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "125", "containsNum": 181923, "orderBy": "574", "tagDesc": "趣味视频、日常生活记录视频、开箱视频....分享送你上首页推荐!\n\n", "tagId": 1263, "tagName": "每日视频打卡", "thumb": "https://du.hupucdn.com/lnFKpWrTBz2N25MdzBU2Yti76vT6", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" } ] }, "env": "cs", "log": null, "msg": "成功", "status": 200, "timestamp": 0.075935125350952}

Python脚本:


import json, os
response_data = { "data": { "existOfflineClockin": 0, "go": 'true', "lastId": "", "list": [ { "clockInId": "19", "containsNum": 1971522, "orderBy": "665", "tagDesc": "鞋狗每日打卡!晒晒你的宝贝球鞋\n欢迎分享:球鞋上脚照、入手感受、搭配建议等\n图片、文字符合主题,可获得更多点赞和关注!", "tagId": 295, "tagName": "今天只晒鞋", "thumb": "https://du.hupucdn.com/Fu1T5EEUemk6sW6210x8O5M7-woi", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "47", "containsNum": 1594616, "orderBy": "663", "tagDesc": "OOTD,来分享你的每日穿搭~", "tagId": 9, "tagName": "今天穿什么", "thumb": "https://du.hupucdn.com/FtoOBG0AM6e0MYXcEvxq6Rctcbjs", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "126", "containsNum": 87783, "orderBy": "657", "tagDesc": "欢迎分享各类体育比赛视频,送你上首页推荐!", "tagId": 267, "tagName": "体育精彩视频分享", "thumb": "https://du.hupucdn.com/lghvdJY0hjTdIOHV870o1-l41SHl", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "138", "containsNum": 83280, "orderBy": "655", "tagDesc": "欢迎分享你喜爱的、想推荐的说唱音乐视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 1360, "tagName": "说唱音乐视频分享", "thumb": "https://du.hupucdn.com/Fr1A4aB9BxdLb_RrHZ84WI6Cj8o7", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "140", "containsNum": 68899, "orderBy": "650", "tagDesc": "欢迎分享你喜爱的、想推荐的街舞视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 247, "tagName": "街舞视频分享", "thumb": "https://du.hupucdn.com/FoAfCBfHKIfxvr5pWPjvxvBelfZY", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "25", "containsNum": 293796, "orderBy": "644", "tagDesc": "康康你的自拍照,有机会上首页推荐哦!", "tagId": 310, "tagName": "就是爱自拍", "thumb": "https://du.hupucdn.com/Fn3LjHqtx1mR1TsJhhIuMzklPzC0", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "147", "containsNum": 220616, "orderBy": "643", "tagDesc": "让我康康仙女都在买啥(⊙_⊙)", "tagId": 1595, "tagName": "美妆种草", "thumb": "https://du.hupucdn.com/FpeNLkzEWUeckefHu0gxqFKPqvab", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "83", "containsNum": 1498983, "orderBy": "642", "tagDesc": "那些你最喜欢的壁纸,和大家一起分享吧~", "tagId": 249, "tagName": "每日一张壁纸", "thumb": "https://du.hupucdn.com/Fm5FlcDrKBPvRZr67F-nJKEdaj6r", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "15", "containsNum": 72869, "orderBy": "640", "tagDesc": "不怕车不帅就怕你不发,冲!", "tagId": 16, "tagName": "就想晒个车", "thumb": "https://du.hupucdn.com/FjFXqQEyo6aAh9MrKQb787m-LBxy", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "67", "containsNum": 78132, "orderBy": "638", "tagDesc": "入手了新玩具?快来晒晒吧!有机会上首页推荐哦!", "tagId": 259, "tagName": "晒下新玩具", "thumb": "https://du.hupucdn.com/FnKepVPzANQsDvrTiomW7kWZubIs", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "3", "containsNum": 68547, "orderBy": "636", "tagDesc": "来这里,记录你的坚持与汗水!记得每日来打卡哦!", "tagId": 311, "tagName": "每日运动打卡", "thumb": "https://du.hupucdn.com/FkpHtyz3peiEPM_sB9WpfmGcfpBO", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "139", "containsNum": 27149, "orderBy": "634", "tagDesc": "欢迎分享你喜爱的、想推荐的电音视频!\n建议:清晰无水印、写出作品名称、作者名字、你想推荐的理由\n质量越高的内容,越容易获得更多曝光哦!", "tagId": 944, "tagName": "电音视频分享", "thumb": "https://du.hupucdn.com/FjoGu5hvULvDfX8obhAh742zsOxi", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "142", "containsNum": 8309, "orderBy": "632", "tagDesc": "板仔集合,秀出你的滑板技能!", "tagId": 1154, "tagName": "我的滑板日常", "thumb": "https://du.hupucdn.com/Ftx6RZSUqR1uHpmzeoZytO7LtXaA", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "9", "containsNum": 2733545, "orderBy": "576", "tagDesc": "每天都要潮出不一样", "tagId": 302, "tagName": "潮流生活打卡", "thumb": "https://du.hupucdn.com/FjTjA377QeYZDf9oyKyykaNi8L3w", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" }, { "clockInId": "125", "containsNum": 181923, "orderBy": "574", "tagDesc": "趣味视频、日常生活记录视频、开箱视频....分享送你上首页推荐!\n\n", "tagId": 1263, "tagName": "每日视频打卡", "thumb": "https://du.hupucdn.com/lnFKpWrTBz2N25MdzBU2Yti76vT6", "userContinuousNum": "0", "userHistoryNum": 0, "userJoined": "0", "userRank": "-", "userTodayJoined": "0" } ] }, "env": "cs", "log": 'null', "msg": "成功", "status": 200, "timestamp": 0.072869062423706}

class ModifyResponse:
def response(self, flow): # 拦截指定的url if flow.request.url.startswith('https://m.dewu.com/sns/v1/tag/clockin-topic-list'): # 设置响应据 flow.response.set_text ( json.dumps(response_data) )

addons = [ ModifyResponse()]

启动mitmproxy代理并启动python脚本实时监控

cmd下执行

mitmweb -p 8989 -s C:\Users\xia\Desktop\AutoTest\srzp_api_test\main\test.py

ba527699feb063f248abaec30dba485a.webp

发现请求url中有接口地址:https://m.dewu.com/sns/v1/tag/clockin-topic-list 把未打卡时的响应数据返给APP,APP端呈现出立即打卡亮起状态,可操作再次立即打卡,达到要测试的效果。


当然也可以更改响应数据的打卡状态为非0非1,测似默认状态下button是怎么展示的?接口响应数据还没回来时,怎么展示的?等等



浏览 48
点赞
评论
收藏
分享

手机扫一扫分享

分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

分享
举报