i'm not seeing possible using requests module, maybe i'm missing something...
i need able capture live http header data that, example, firefox plugin such creatively named live http headers plugin
is there method capturing header data can collect following (or close following possible)?:
https://instagram.com/oauth/authorize/?client_id=cb0096f08a3848e6a355f&redirect_uri=https://pythondev.geometryfletch.com/instagramredirect.html&response_type=code&hl=hu /oauth/authorize/?client_id=cb0096f08a3848e6a355f&redirect_uri=https://pythondev.geometryfletch.com/instagramredirect.html&response_type=code&hl=hu http/1.1 host: instagram.com user-agent: mozilla/5.0 (macintosh; intel mac os x 10.9; rv:38.0) gecko/20100101 firefox/38.0 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate cookie: csrftoken=4d9696d270a1d2d7b4d1b5; mid=u8lmswaeaagyemgtjenk; __utma=227057989.1190820776.1417498356.1417498356.1417498356.1; sessionid=igscb5786690876faa5d2505e1d8b3782691614164cb344c52ec2a6714cb5e1cd884%3akds8ralygangbeqmailu%3a%7b%22_token_ver%22%3a1%2c%22_auth_user_id%22%3a324232c%22_token%22%3a9437%3a1lhxddvrnvbt4ms1j5qpebmg%3ac0ccc4aebd1d88175db75c9ce360ad595c55946577bcb9ebc%22%2c%22_auth_user_backend%22%3a%22accounts.backends.caseinsensitivemodelbackend%22%2c%22last_refreshed%22%3a1436481638.349811%2c%22_platform%22%3a4%7d; ds_user_id=324239437 connection: keep-alive http/1.1 302 found cache-control: private, no-cache, no-store, must-revalidate content-language: hu content-type: text/html; charset=utf-8 date: thu, 09 jul 2015 22:46:21 gmt expires: sat, 01 jan 2000 00:00:00 gmt location: https://pythondev.devtesting.com/instagramredirect.html?code=2c49fd7803384c6c5a89cee pragma: no-cache set-cookie: csrftoken=4d9696dac6b0d5b8591b5; expires=thu, 07-jul-2016 22:46:21 gmt; max-age=31449600; path=/ vary: cookie, accept-language content-length: 0 connection: keep-alive all need out of url string value location likes this:
location: https://pythondev.devtesting.com/instagramredirect.html?code=2c49fd7803384c6c5a89cee after searching around possible solutions, i've been trying variations on following (client_id , redirect altered post):
oauthurl = "https://api.instagram.com/oauth/authorize/?client_id=cb00962b4601317355f&redirect_uri=https://pythondev.instadev.com/instagramredirect.html&response_type=code" r = requests.get(oauthurl, stream=true) print r.raw.data but obviously, garbled stuff:
ôr˼ÖtÉxlÏß5g·Ì{þµ¼æ®6×mƦ¶Ök:µ#î^bm,\ûf+ÈÕúµçoo´Úö3ut×]ta¡*_@[bsÊqgÅëêw×ûqÁç)óf-Õd[³Û®3×*ï¥Ôï`æ:$nÑÞz£ô)©ª[}«Øba"¿²å¿*ÜÞ1buĹ!dgwËuhµ?:pnmwbâÿk¯ÈiÅ¡#2r¸@¼'ø>"dptoÈm"w fÞ xöñ¯vmg cÆÔ>÷οaâykãyk¤=²"ù*a¦=ýz=²3&¤ö©½õ cËimÛÓ¯6Î(íirg*« would sockets work this? or there module out there use allow me collect header same way web browser http header plugin would?
requests returns headers you. can use dict-style access them.
if want request.get return redirect response rather automatically following it, specify allow_redirects=false.
#untested oauthurl = "https://api.instagram.com/oauth/authorize/?client_id=cb00962b4601317355f&redirect_uri=https://pythondev.instadev.com/instagramredirect.html&response_type=code" r = requests.get(oauthurl, stream=true, allow_redirects=false) print r.headers.keys() print r.headers['location'] alternatively, specify allow_redirects=true (the default value), , examine r.history:
#untested oauthurl = "https://api.instagram.com/oauth/authorize/?client_id=cb00962b4601317355f&redirect_uri=https://pythondev.instadev.com/instagramredirect.html&response_type=code" r = requests.get(oauthurl, stream=true, allow_redirects=true) print [resp.headers['location'] resp in r.history]
Comments
Post a Comment