当前位置:网站首页>[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')
边栏推荐
猜你喜欢
随机推荐
少儿编程 电子学会图形化编程等级考试Scratch三级真题解析(判断题)2022年6月
中国SaaS企业排名,龙头企业Top10梳理
APS系统能消除造成生产和运输延迟的瓶颈
Forbidden (CSRF token missing or incorrect.): /
如何正则匹配乱码?
PyQt5:入门使用教程
Leetcode 98. 验证二叉搜索树
Miscellaneous talk - the sorrow of programmers
“我“是一名测试/开发程序员,小孙的内心独白......
外包的水有多深?腾讯15k的外包测试岗能去吗?
VR全景拍摄如何拍摄?如何使用拍摄器材?
leetcode:319. 灯泡开关
制定量化交易策略的基本步骤有哪些?
34. Fabric2.2 证书目录里各文件作用
三:OpenCV图片颜色通道数据转换
VR全景结合小程序,为线上电商更好的服务
如何知道电脑开机记录?
70. 爬楼梯进阶版
毕昇编译器优化:Lazy Code Motion
UNI-APP_监听页面滚动h5监听页面滚动