처음부터 차근차근

requests 라이브러리 본문

Language/Python

requests 라이브러리

HangJu_95 2023. 5. 4. 17:28
728x90

requests 라이브러리는 파이썬에서 HTTP를 사용하기 위해 쓰여지는 라이브러리로, 표준처럼 널리 쓰이고 있는 라이브러리이다.

 

requests의 API로는 HTTP 요청 방식에 따라 해당하는 이름의 함수를 사용하면 된다.


GET 방식: requests.get()
POST 방식: requests.post()
PUT 방식: requests.put()
DELETE 방식: requests.delete()

 

오늘은 Get 방식을 설명한다.

 

import requests # requests 라이브러리 설치 필요

rjson = r.json()

print(rjson)

Requests.get을 통해 해당 http의 데이터를 가져올 수 있으며,

r.json()을 통해 딕셔너리 타입으로 바로 변환하였다.

 

 

이외에도 해당 사이트에 들어가 requests에 대한 정보를 얻을 수 있다.

https://docs.python-requests.org/en/latest/user/quickstart/

 

Quickstart — Requests 2.30.0 documentation

Eager to get started? This page gives a good introduction in how to get started with Requests. Let’s get started with some simple examples. Passing Parameters In URLs You often want to send some sort of data in the URL’s query string. If you were const

docs.python-requests.org

 

'Language > Python' 카테고리의 다른 글

beautifulsoup 사용법  (0) 2023.05.04
Python 가상 환경 설치  (0) 2023.05.04
Python Git bash 설치  (0) 2023.05.04