def extract_cookies(cookie):
"""从浏览器或者request headers中拿到cookie字符串,提取为字典格式的cookies"""
cookies = dict([l.split("=", 1) for l in cookie.split("; ")])
return cookies
if __name__ == "__main__":
cookie = "continue=http://www.bj.10086.cn/service/fee/zdcx/; continuelogout=http://www.bj.10086.cn/service/fee/zdcx/; CmLocation=100|100; CmProvid=bj; WT_FPC=id=2e4f7c373760da4bead2e31489565793714:lv=1489635199762:ss=1489635053131; Webtrends=58.132.171.245.1489565794320746; JSESSIONID=0000UGBr1eur3P3Yp6EalieXCp8GP2T:16vf1jlcr; input_loginName=15210357242; c_loginName=15210357242; SSOTime=2017-03-15 16:17:16; [email protected]@[email protected]@1489565836722"
cookies = extract_cookies(cookie)
---------------------
作者:鑫元帅
来源:CSDN
原文:https://blog.csdn.net/Frank_King/article/details/78252643
版权声明:本文为博主原创文章,转载请附上博文链接!
原文地址:https://www.cnblogs.com/duanlinxiao/p/9824239.html