defcookies_raw_to_dic(cookie_raw_):"""
通过原始cookie转换cookie字典
:param cookie_raw_: 浏览器原始cookie
:return: 字典-cookies
"""
cookies_dict ={}for line in cookie_raw_.strip("\n").split("; "):
key, value = line.split("=",1)
cookies_dict[key]= value
# print(cookies_dict)# return dict(line.split("=", 1) for line in cookie_raw.split("; "))return cookies_dict
cookie_raw = r"""
BrowserId=sLz7_STyT12tV4xly6RdOQ;QCQQ=C5hPsneBh1y;oinfo=c3RhdHVzPUFDVElWRSZ0eXBlPTImb2lkPTAwRDI4MDAwMDAxMjdHZQ==;autocomplete=1;sid=00D2800000127Ge!AQUAQLgf1650cJO58cc6yk0IZt8iuGXjkJM_uSHgi0yFdp9BDUkTBi_08xiQ59HqGvAZ3DY_srKmD5IQcqpDqW8U29rwTm5t;sid_Client=8000004Luae800000127Ge;clientSrc=223.104.63.26;inst=APP_0I;oid=00D2800000127Ge;alohaEpt=SatAug18201814:34:35GMT+0800
"""
cookies = cookies_raw_to_dic(cookie_raw)print(cookies)