import requests

# HTML 소스 가져오기
def HTMLsouceGet(p):
print (p.text)

# HTTP 헤더 정보
def HTTPheaderGet(p):
retV = p.headers
return retV

def HTTPstatusGet(p):
print (p.status_code)

def main():
# GET방식으로 요청
req = requests.get(url='http://www.kitri.re.kr/academy/it_education/job_status2009.web')
is_ok = req.ok
print ("is_ok => {result}".format(result = is_ok))
if req.ok:
HTTPstatusGet(req)
d = HTTPheaderGet(req)
for i in d.keys():
print (i, d[i], sep='=> ')

else:
print ("요청 에러")

if __name__ == "__main__":
main()
 
is_ok => True
200
Date=> Sun, 11 Mar 2018 06:17:49 GMT
Server=> Apache/2.2.15 (CentOS)
Set-Cookie=> JSESSIONID=B27FC1FD587B1967B6F36A6A8755CA45; Path=/; HttpOnly
Content-Language=> ko-KR
Connection=> close
Transfer-Encoding=> chunked
Content-Type=> text/html;charset=UTF-8
 
 

 


 

'python > request + bs4' 카테고리의 다른 글

데이트를 위해 맛집 크롤링 중  (0) 2018.11.22