chrome浏览器请求头格式化输出成 python dict字典

因为经常使用head头去请求网站,每次复制太麻烦,写了个util方法,记录一下。
只需要把谷歌请求头复制下来把heads替换掉就能用

# -*- coding: utf-8 -*-
from lxpy import copy_headers_dict

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-CN,zh;q=0.9
Cache-Control: no-cache
Connection: keep-alive
Cookie: ll="118091"; bid=XFRsLwrz81M; push_noty_num=0; push_doumail_num=0; dbcl2="249449316:gjeVE/jJwlY"; ct=y; ck=_VCi; ap_v=0,6.0
Host: movie.douban.com
Pragma: no-cache
Referer: https://www.douban.com/
sec-ch-ua: ".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-site
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/103.0.0.0 Safari/537.36
"""
headers = copy_headers_dict(headers)
print(headers)

字典在线格式化:https://www.sojson.com/