复制谷歌请求头的简单处理

str ="""
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 150
Content-Type: application/x-www-form-urlencoded
Cookie: pgv_pvid=5289973183; __qc_wId=248; JSESSIONID=E6F956C723D0BE4ADDFDF45BFB28A15D; Hm_lvt_f2d726882e87f6b9f128f4e93000ff47=1539333316,1539334528,1539336615,1539336619; Hm_lpvt_f2d726882e87f6b9f128f4e93000ff47=1539336619
Host: login.zlbaba.com
Origin: https://login.zlbaba.com
Pragma: no-cache
Referer: https://login.zlbaba.com/login?service=https://www.patexplorer.com/login/cas
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36
"""
data = {}
# 请求头处理
for i in str.split('\n'):
    if i:
        data[i.split(':')[0].strip()] = i.split(':')[1].strip()
print(data)
# # 代理处理
# cookie = data['Cookie']
# cookies = 'UM_distinctid=1666726ac9d3bf-01ffab5f1d1987-541f3415-1fa400-1666726ac9e456; Hm_lvt_c9626224f562d87fd1862b3f365dcd00=1539330685,1539330702,1539331465,1539332073; CNZZDATA1261546263=61757800-1539324092-https%253A%252F%252Fwww.patexplorer.com%252F%7C1539329493; JSESSIONID=364987122632EE8630A802D0443A6EC6; yunsuo_session_verify=2546d202ec4ec197693b3a0626dc741e; PD=a0bf551aaa865492b3b7c974277516c3df9985758bf10e5ef8f541b24b358261aa21b08727f13d7f; Hm_lpvt_c9626224f562d87fd1862b3f365dcd00=1539332339'
# info = {}
# for i in cookies.split(';'):
#     j = i.strip()
#     if j:
#         info[j.split('=')[0]] = j.split('=')[1]
# print(info)

你可能感兴趣的:(复制谷歌请求头的简单处理)