python - Requests dict from cookiejar issue with escaped chars -


i'm running issues getting cookie dictionary python. seems escaped somehow after running command provided requests.

resp = requests.get(geturl, cookies=cookies) cookies = requests.utils.dict_from_cookiejar(resp.cookies) 

and cookies looks

{'p-fa9d887b1fe1a997d543493080644610': '"\\050dp1\\012s\'variant\'\\012p2\\012s\'corrected\'\\012p3\\012ss\'pid\'\\012p4\\012vnta2nju0otu4mdc5mtgwoa\\075\\075\\012p5\\012ss\'format\'\\012p6\\012s\'m3u8\'\\012p7\\012ss\'mode\'\\012p8\\012vlive\\012p9\\012ss\'type\'\\012p10\\012s\'video/mp2t\'\\012p11\\012s."'} 

is there way make characters unescaped in value section of p-fa9d887b1fe1a997d543493080644610 become escaped , part of dict itself?

edit:

i dictionary like:

{'format': 'm3u8', 'variant': 'corrected', 'mode': u'live', 'pid': u'nta2nju0otu4mdc5mtgwoa==', 'type': 'video/mp2t'} 

you dealing python pickle format data serialisation. once have evaluated expression, escaped characters unescaped, need load pickle string using pickle.loads function.

>>> import pickle >>> import ast >>> pickle.loads(ast.literal_eval("'''" + cookies.values()[0] + "'''")[1:-1]) {'pid': u'nta2nju0otu4mdc5mtgwoa==', 'type': 'video/mp2t', 'variant': 'corrected', 'mode': u'live', 'format': 'm3u8'} 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -