Loading

DATA

python headers请求头格式化
代码如下:header = '''Accept: text/html,application/xhtml+xml,...
扫描右侧二维码阅读全文
28
2021/09

python headers请求头格式化

代码如下:

header = '''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
Cache-Control: no-cache
Connection: keep-alive
Cookie: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Host: www.baidu.com
Pragma: no-cache
sec-ch-ua: "Google Chrome";v="93", " Not;A Brand";v="99", "Chromium";v="93"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36'''
head = header.split("\n")
for i in range(0,len(head)):
    henders = head[i].split(": ")
    headers = '"'+henders[0]+'"'+": "+'"'+henders[1]+'"'+','
    print(headers)
最后修改:2021 年 09 月 28 日 04 : 16 PM
如果觉得我的文章对你有用,请随意赞赏

发表评论