2016-12-19 9 views
0

私はpython要求を使用して応答の場所を取得する方法を見つけようとしています。私がfiddlerを使うとき、またはpythonのリクエストを使うとき、返されたヘッダはそれが来た場所を含まない。私のブラウザで同じ要求を見ると、応答の場所が表示されます。とにかくこれをやっている? おかげでここpythonが応答の場所を要求します

答えて

0

urllib2を使用した例ですが、私はあなたがrequestsでそれを行うことができるとは思わない:getting value of location header using python urllib2

>>> urllib2.urlopen('http://google.com').info().__dict__ 
{'fp': None, 'status': '', 'startofbody': None, 'startofheaders': None, 'subtype': 'html', 'type': 'text/html', 'maintype': 'text', 'headers': ['Date: Mon, 19 Dec 2016 23:11:59 GMT\r\n', 'Expires: -1\r\n', 'Cache-Control: private, max-age=0\r\n', 'Content-Type: text/html; charset=ISO-8859-1\r\n', 'P3P: CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."\r\n', 'Server: gws\r\n', 'X-XSS-Protection: 1; mode=block\r\n', 'X-Frame-Options: SAMEORIGIN\r\n', 'Set-Cookie: NID=93=TKYj49Z3JkIbdrSKS3TgOIKLualPZ--E7dYEXg0S4lYvveiaGLAWjXWpy6xNrutXuTkEkaUH5u1K8Gq8jbWaG5uDENsg3deeSOWNFqCM-YCIe_TZMeu7eUj3PW5__Yzid7gpeUUiEiNa0Q; expires=Tue, 20-Jun-2017 23:11:59 GMT; path=/; domain=.google.com; HttpOnly\r\n', 'Accept-Ranges: none\r\n', 'Vary: Accept-Encoding\r\n', 'Connection: close\r\n'], 'dict': {'x-xss-protection': '1; mode=block', 'set-cookie': 'NID=93=TKYj49Z3JkIbdrSKS3TgOIKLualPZ--E7dYEXg0S4lYvveiaGLAWjXWpy6xNrutXuTkEkaUH5u1K8Gq8jbWaG5uDENsg3deeSOWNFqCM-YCIe_TZMeu7eUj3PW5__Yzid7gpeUUiEiNa0Q; expires=Tue, 20-Jun-2017 23:11:59 GMT; path=/; domain=.google.com; HttpOnly', 'accept-ranges': 'none', 'expires': '-1', 'vary': 'Accept-Encoding', 'server': 'gws', 'connection': 'close', 'cache-control': 'private, max-age=0', 'date': 'Mon, 19 Dec 2016 23:11:59 GMT', 'p3p': 'CP="This is not a P3P policy! See https://www.google.com/support/accounts/answer/151657?hl=en for more info."', 'content-type': 'text/html; charset=ISO-8859-1', 'x-frame-options': 'SAMEORIGIN'}, 'typeheader': 'text/html; charset=ISO-8859-1', 'encodingheader': None, 'seekable': 0, 'unixfrom': '', 'plisttext': '; charset=ISO-8859-1', 'plist': ['charset=ISO-8859-1']} 

ここでは、次の答えではより多くの情報です。

関連する問題