Python--格式化cookie为字典类型

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&timestamp=0.9136645394'
data = {'page': 1, 'limit': 20}

r = requests.get(url, data, cookies=cookie)

print(r.json())
posted @ 2018-02-09 16:30  王思磊  阅读(597)  评论(0编辑  收藏  举报