지속가능티끌/Python
Python. requests 모듈. http post get
i.got.it
2020. 3. 18. 12:52
파이썬 requests 모듈
- http post get 실행가능.
- 간단히 기본 get 실행시켜보기.
import requests
URL = "https://igotit.tistory.com"
res = requests.get(URL);
print(res.status_code);
print(res.text);
실행결과.
403
<!doctype html>
<html lang="ko">
<head>
<title>TISTORY</title>
.... (생략)
post
my_data = {'param1': 'value1','param2': 'value2'}
res = requests.post(url, data=my_data);
아이디 비번 전달
url = "https://naver.com"
res=request.post(url, auth=("id", "pass"));
print("status code : " res.status_code);
get
my_para = {'param1': 'value1','param2': 'value2'}
res = requests.get(url, params=my_para);
response
- get, post 의 응답
response.status_code : 응답코드.
response.jason() : jason 타입 response 를 파이썬 딕셔너리 타입으로 변환.
첫 등록 : 2020.03.18
최종 수정 :
단축 주소 : https://igotit.tistory.com/2491