当前位置:网站首页>[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')边栏推荐
猜你喜欢
随机推荐
OSG笔记:使用setFontResolution设置字体分辨率
都在说云原生,那云原生到底是什么?
力扣:279.完全平方数
后台管理实现导入导出
leetcode:321. 拼接最大数
干涉BGP的选路---社团属性
上海一科技公司刷单被罚22万,揭露网络刷单灰色产业链
ArrayList 和 LinkedList 区别
干货!迈向鲁棒的测试时间适应
daemon
集群的基础形式
mysql中的key是怎么用的,或者这个值有什么意义,如下图?
Forbidden (CSRF token missing or incorrect.): /
全面解析FPGA基础知识
杭电多校-Counting Stickmen-(思维+组合数+容斥)
matplotlib散点图颜色分组图例
离散选择模型之Gumbel分布
SRv6性能测量
(转)FreeType字体位图属性
VR全景结合小程序,为线上电商更好的服务









