In [1]: b = "_ga=GA1.2.1744018037.1530169793; user_trace_token=20180628150953-41
...: 4c1c58-7aa2-11e8-9759-5254005c3644; LGUID=20180628150953-414c1f68-7aa2-1
...: 1e8-9759-5254005c3644; index_location_city=%E5%8C%97%E4%BA%AC; _gid=GA1.
...: 2.1832481109.1531293590; JSESSIONID=ABAAABAAAGGABCB4C47F3C690ED2FD1921CA
...: B85F19269F5; Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6=1530169793,15312935
...: 90,1531297077; TG-TRACK-CODE=index_navigation; Hm_lpvt_4233e74dff0ae5bd0
...: a3d81c6ccf756e6=1531298760; LGRID=20180711164559-d5d086f6-84e6-11e8-8853
...: -525400f775ce; SEARCH_ID=b075722a11784824a1a7592818e13678"
In [2]: cookie = {}
In [3]: for line in b.split(';'):
...: key,value = line.split('=',1)
...: cookie[key] = value
...:
In [4]: cookie
{'_ga': 'GA1.2.1744018037.1530169793',
' user_trace_token': '20180628150953-414c1c58-7aa2-11e8-9759-5254005c3644',
' LGUID': '20180628150953-414c1f68-7aa2-11e8-9759-5254005c3644',
' index_location_city': '%E5%8C%97%E4%BA%AC',
' _gid': 'GA1.2.1832481109.1531293590',
' JSESSIONID': 'ABAAABAAAGGABCB4C47F3C690ED2FD1921CAB85F19269F5',
' Hm_lvt_4233e74dff0ae5bd0a3d81c6ccf756e6': '1530169793,1531293590,1531297077',
' TG-TRACK-CODE': 'index_navigation',
' Hm_lpvt_4233e74dff0ae5bd0a3d81c6ccf756e6': '1531298760',
' LGRID': '20180711164559-d5d086f6-84e6-11e8-8853-525400f775ce',
' SEARCH_ID': 'b075722a11784824a1a7592818e13678'}
参考文章:https://blog.csdn.net/taojijisky/article/details/79487193
网友评论