import requests
cookies = ‘dy_did=d94fe220c9ac1c014987ec5e00061501; _dys_refer_action_code=init_page_studio_v; acf_yb_auth=e5a8f675af47acaeaf434cad94061d119ee35ab6; acf_yb_new_uid=OVAOGxPZJAQk; acf_yb_uid=23577717; wan_auth37wan=e905f01aeff1ABnq4XOGY5v7evce6pDdBQF3bnaqgNPpVsAJYE%2Fw4JINiGuP%2Br1fw%2FUMRHDUlCFbvgsjHZhXe1ZgiiS5zU2oAxPzLfBb8VGnznzflQ; smidV2=201802071500113f502a3e75dea9ef6790f8a6a89a4d7a004fe7c47bd11b8b0; Hm_lvt_e99aee90ec1b2106afe7ec3b199020a7=1517977429,1517980745,1517984460,1517985641; Hm_lpvt_e99aee90ec1b2106afe7ec3b199020a7=1517993736; Hm_lvt_e0374aeb9ac41bee98043654e36ad504=1517984538,1517984544,1517984752,1517985645; Hm_lpvt_e0374aeb9ac41bee98043654e36ad504=1517993742; acf_yb_t=2CXdVSPU2x9KSccGsaHmGOp14pZSnrUj‘
lists = cookies.split(‘;‘)
cookie = {}
for i in lists:
j = i.strip()
j = j.split(‘=‘)
cookie[j[0]] = j[1]
url = r‘https://yuba.douyu.com/wbapi/web/user/followList/5748?page=1&limit=20×tamp=0.9136645394‘
data = {‘page‘: 1, ‘limit‘: 20}
r = requests.get(url, data, cookies=cookie)
print(r.json())
Python--格式化cookie为字典类型
Posted 王思磊
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python--格式化cookie为字典类型相关的知识,希望对你有一定的参考价值。
以上是关于Python--格式化cookie为字典类型的主要内容,如果未能解决你的问题,请参考以下文章
python字典转化成json格式。JSONEncoder和JSONDecoder两个类来实现Json字符串和dict类型数据的互相转换