工具编写原因
这个帖子里的请求头格式化工具我用了很久,但是会删除字典value字符串里的空格,
[原创工具] python请求头格式化 [b]https://www.52pojie.cn/thread-1483388-1-3.html[/b]
大部分时候没什么问题,但是有时候我也用来格式化data,params参数,空格除去之后,参数不正确,导致请求结果返回错误。
然后花费了很长时间,才发现这个是因为去掉了字符串里的空格。因此编写此请求头格式化工具,基于python实现,使用了tkinter库进行可视化,pyinstaller 进行打包
功能
- 请求头格式化
- V1.1.2 增加自动复制格式化结果到粘贴板
演示
输入:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate, br
Accept-Language: zh,zh-CN;q=0.9,en-US;q=0.8,en;q=0.7,zh-HK;q=0.6
Cache-Control: no-cache
Connection: keep-alive
Cookie: KF4=K5wI7H; htVD_2152_connect_is_bind=1;
dnt: 1
sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
sec-gpc: 1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36
输出:
headers = {
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'zh,zh-CN;q=0.9,en-US;q=0.8,en;q=0.7,zh-HK;q=0.6',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
'Cookie': 'KF4=K5wI7H; htVD_2152_connect_is_bind=1;',
'dnt': '1',
'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'Sec-Fetch-Dest': 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'same-origin',
'Sec-Fetch-User': '?1',
'sec-gpc': '1',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36'
}
演示截图
版本
2022-02-12_V1.1.1
- 修复了":"开头的字符串格式化错误的问题
eg
:authority: blog.csdn.net
:method: GET
:path: /qq_30468133/article/details/84946416
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: zh-CN,zh;q=0.9,zh-TW;q=0.8,en;q=0.7```
2022-02-13_V1.1.2
- 重构了可视化部分的代码
- 新增自动复制格式化结果到粘贴板,
小技巧,windows平台下,win+v可以查看剪贴板
下载地址 V1.1.2
[hide]https://wwe.lanzouw.com/i1e1mzzthcd[/hide]