python - How to grab/generate a cookie for a site -


when go amazon.com in browser, sets cookie , sends header:

connection:keep-alive cookie:x-wl-uid=1dxbakbjj9ys0awdahh9dlcljmdr8xcztyvpl8p8ojo8mnjbeo/zbskq8w/jsw7cllsm90d2olfs=; session-token=/ncn9s4+yfweyvyk0kiolkdyy2xx9l17ag/zuzdy+5vh88wsk5n0+fcldn9f/y+xe/rnpkjev1ijrjsogp26ovt5+ejynfz6c/usfqkh3cxgzqkxxossa5yxo9kd9s3yhpzbkzfgu1f63hns1kql/iivchs3fvpmldqmyxtion0h05exwvcndnio1ys8qu0w5lvosvuc45cuyqpi3n+7qi86aohgjwhs/cm534xpcehsb+xn0ndrwfnjvhswnkr9; skin=noskin; ubid-acbjp=376-3466160-3751758; session-id-time=2082726001l; session-id=378-0276221-0879566; csm-hit=s-0gjw8d60qfn7xax43ce2|1433025870016 host:www.amazon.co.jp 

how grab cookie in order insert requests.get() call? in other words, how request fill in cookie in following:

headers = {   "accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",   "accept-encoding" : "gzip, deflate, sdch",   "accept-language" : "en-us,en;q=0.8,pt;q=0.6",   "connection" : "keep-alive",   "cookie" : "??????????",   "host": "ww.amazon.com",   "user-agent": "mozilla/5.0 (macintosh; intel mac os x 10_10_0) applewebkit/537.36 (khtml, gecko) chrome/43.0.2357.81 safari/537.36" } 

create session object, , make requests context of session:

s = requests.session() url = "http://www.amazon.com" r = s.get(url) 

Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -