当前位置:网站首页>[Interface Test] Decoding the request body string of the requests library
[Interface Test] Decoding the request body string of the requests library
2022-08-10 00:32:00 【Warolitbos】
Interface test request body
When performing automated interface testing, I hope to record my interface requests through logs.
At this point, I encountered the following problem:
When the method of the request body is
form format
, the obtained request body, the string encoding format is not parsed
This is not convenient for my subsequent test report or test analysis of test code errors through logs.Among them, I have related methods to use the requests
library to solve this problem, but the methods I found are all for the parsing operation of return body
, not for requestsThe parsing operation of the body
, so I fall back and use the parsing method of the urllib
library for parsing
Note: I have searched for many methods, but have not found any relevant articles!Therefore, this article is published in the hope that it can help the majority of netizens!Of course, if the majority of netizens have better suggestions, please let us know in the comment area
Tried using
request.encoding
, but the challenge with this encoding format is the return content!At this point, I thought that the URL will also encode the string itself when requesting.
Finally, I provide an idea myself, that is, Use the built-in library for decoding
, and some friends have a better method in the future, or know that requests
has its own decoding methodYes, welcome to leave a message in the comment area
String decoding
from urllib.parse import unquotetext = unquote(text, 'utf-8')
At the same time, a method for encoding strings is provided, for reference only!
String encoding
from urllib.parse import quotetext = quote(text, 'utf-8')
边栏推荐
- CV review: softmax code implementation
- 2021年国内外五大BI厂商——优秀的商业智能工具推荐
- 【Burning】It's time to show your true strength!Understand the technical highlights of the 2022 Huawei Developer Competition in one article
- setter与getter访问器属性——数据驱动显示
- Day 12 of learning to program
- What are the basic steps to develop a quantitative trading strategy?
- 多线程是同时执行多个线程的吗
- Leetcode 235. 二叉搜索树的最近公共祖先
- tiup cluster scale-out
- Janus Official DEMO Introduction
猜你喜欢
随机推荐
Basic operations of xlrd and xlsxwriter
[WeChat applet development (8)] Summary of audio background music playback problems
深度学习100例 —— 循环神经网络(RNN)实现股票预测
OSG笔记:使用setFontResolution设置字体分辨率
安踏携手华为运动健康共同验证冠军跑鞋 创新引领中国体育
(转)字符集编码标识符,数字表示字符编码
干涉BGP的选路---社团属性
JS中表单操作、addEventListener事件监听器
少儿编程 电子学会图形化编程等级考试Scratch三级真题解析(判断题)2022年6月
杂谈——程序员的悲哀
Miscellaneous talk - the sorrow of programmers
高数_复习_第4章:向量代数和空间解析几何
EasyExcel使用
华为云全流程护航《流浪方舟》破竹首发,打造口碑爆款
如何知道电脑开机记录?
CV review: softmax code implementation
OSS文件上传
干货!迈向鲁棒的测试时间适应
PyQt5:入门使用教程
Leetcode 236. 二叉树的最近公共祖先