-
Requests Library in pythonProgramming Language/Python 2019. 12. 5. 00:42반응형
Requests
라이센스
Apache Software License (Apache 2.0)
특징
- python으로 작성된 HTTP library
- HTTP/1.1 request 사용 가능
- headers, form data, paramters 등등을 간단히 추가 가능
설치
pip install requests
Import 방법
import requests
Method 종류
- GETparams : Dictionary, list of tuples or bytes
requests.get(url, params=None, **kwargs)
- OPTIONS
requests.options(url, **kwargs)
- HEAD
requests.head(url, **kwargs)
- POSTdata : Dictionary, list of tuples or bytes
json : json data requests.post(url, data=None, json=None, **kwargs)
- PUTdata : Dictionary, list of tuples or bytes
requests.put(url, data=None, **kwargs)
- PATCHdata : Dictionary, list of tuples or bytes
requests.patch(url, data=None, **kwargs)
- DELETE
requests.delete(url, **kwargs)
간단 사용법
>>> response = requests.get('https://www.python.org') >>> response.status_code 200 >>> response.content b'<!doctype html>\n<!--[if lt IE 7]> <html class=... ... ' >>> response = requests.post('https://www.python.org') >>> response.status_code 403 >>> response = requests.head('https://www.python.org') >>> response.status_code 200
참고 문서
pypi의 requests 문서
Requests 문서
Developer InterfaceccGithub
반응형'Programming Language > Python' 카테고리의 다른 글
[python] CLOSE_WAIT 해결 방법 with TimeoutIterator (0) 2021.05.07 [Python] PLY (Python Lex-Yacc) 정리 - Yacc (0) 2021.04.28 [Python] PLY (Python Lex-Yacc) 정리 - Lex (0) 2021.04.28 문자열 암호화 / 복호화 with Python (0) 2021.02.01 RST (reStructuredText) & Sphinx 문법 정리 (0) 2019.12.09