python headers请求头快速添加

2021-03-22 16:24

阅读:491

标签:text   gecko   xmlhttp   load   class   替换   nec   coding   ted   

import re
#  下方引号内添加替换掉请求头内容
headers_str = """
Accept: application/json, text/javascript, */*; q=0.01
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 77
Content-Type: application/json
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1
X-Apple-App-Id: 632
X-Apple-Frame-Id: daw-10beaddd-c22f-4fd4-8aba-ef4909a721dd
X-Requested-With: XMLHttpRequest
"""
pattern = ‘^(.*?):(.*)$‘
for line in headers_str.splitlines():
    print(re.sub(pattern,‘\‘\\1\‘:\‘\\2\‘,‘,line).replace(‘ ‘,‘‘))

  

技术图片

 

python headers请求头快速添加

标签:text   gecko   xmlhttp   load   class   替换   nec   coding   ted   

原文地址:https://www.cnblogs.com/san357/p/13873553.html

上一篇:APIO2017商旅

下一篇:python文件的读写


评论


亲,登录后才可以留言!