一、格式化过程
在测试的时候或者玩爬虫的时候需要构造请求头,然后从浏览器复制出来的信息没有格式化,如何快速的格式化就是需求,一点点的进步也是效率提升的表现。

Host: www.baidu.com
Connection: keep-alive
Accept: application/json, text/javascript, */*; q=0.01
Sec-Fetch-Dest: empty
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: cors
Referer: https://www.baidu.com/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
首先,打开notepad++编辑器,先按住shift+alt键,然后输入'',

然后,再按住shift+alt键,按方向键,将header内容全部选中,并剪切

然后,再按住shift+alt键,按方向键左,将header内容复制至'',引号中。

最后用ctrl+f,替换空格,并将:替换为':'

最终结果如下所示:
'Host':'www.baidu.com',
'Connection':'keep-alive',
'Accept':'application/json,text/javascript,*/*;q=0.01',
'Sec-Fetch-Dest':'empty',
'User-Agent':'Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/80.0.3987.106Safari/537.36',
'Sec-Fetch-Site':'same-origin',
'Sec-Fetch-Mode':'cors',
'Referer':'https':'//www.baidu.com/',
'Accept-Encoding':'gzip,deflate,br',
'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8',
二、动态结果

网友评论