码迷,mamicode.com
首页 > 编程语言 > 详细

python headers请求头快速添加

时间:2020-10-26 11:20:04      阅读:29      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!