2013-02-28 2 views
4

요청 1.1.0 및 Python 2.6.4 (Python 2.7.2에서도 동일한 동작)입니다.Python Requests : 응답 객체에 'status'헤더가 없습니다.

>>> import requests 
>>> response = requests.get('http://www.google.com') 
>>> response.status_code 
200 
>>> print response.headers.get('status') 
None 

문서에 따르면 "200 OK"와 같은 문자열이있는 헤더 [ 'status'] 항목이 있어야합니다. 나는이 딕셔너리는 '상태'항목을 포함해야한다는 생각을 가지고 곳

>>> response.headers 
{'x-xss-protection': '1; mode=block', 'transfer-encoding': 'chunked', 'set-cookie': 'PREF=ID=74b29ee465454efd:FF=0:TM=1362094463:LM=1362094463:S=Xa96iJQX_9BrC-Vm; expires=Sat, 28-Feb-2015 23:34:23 GMT; path=/; domain=.google.com, NID=67=IH21bLPTK2gLTHCyDCMEs3oN5g1uMV99U4Wsc2YA00AbFt4fQCoywQNEQU0pR6VuaNhhQGFCsqdr0FnWbPcym-pizo0xVuS6WBJ9EOTeSFARpzrsiHh6HNnaQeCnxCSH; expires=Fri, 30-Aug-2013 23:34:23 GMT; path=/; domain=.google.com; HttpOnly', 'expires': '-1', 'server': 'gws', 'cache-control': 'private, max-age=0', 'date': 'Thu, 28 Feb 2013 23:34:23 GMT', 'p3p': 'CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."', 'content-type': 'text/html; charset=ISO-8859-1', 'x-frame-options': 'SAMEORIGIN'} 

Here은 다음과 같습니다

다음은 헤더의 전체 내용이 DICT이다.

내가 잘못 했나요? 당신은 "이유"

>>> x=requests.get("http://apple.adam.gs") 
>>> x.reason 
'OK' 
>>> 

custom.php 포함 찾고있는

답변

2

:

>>> x=requests.get("http://apple.adam.gs/custom.php") 
>>> print x.reason 
Testing 
>>> 
:에

header("HTTP/1.1 200 Testing") 

결과