아미(아름다운미소)

Python3 urllib으로 http로 POST 전송 본문

랭귀지/PYTHON

Python3 urllib으로 http로 POST 전송

유키공 2019. 12. 21. 11:43

Python3 urllib으로 http로 POST 전송

'''
Created on 2019. 12. 21.

@author: test
'''
import urllib.parse
import urllib.request

details = urllib.parse.urlencode({'CODE': '코드', 'NAME': '이름', 'KIND': '종류', 'PRICE': '가격', 'USERID': '아이디'})
details = details.encode('UTF-8')

url = urllib.request.Request('https://test.cafe24.com/postdata_test.php', details)

url.add_header("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.29 Safari/525.13")

ResponseData = urllib.request.urlopen(url).read().decode("utf-8")
print(ResponseData)
.add_header 함수를 사용해 헤더를 추가할 수도 있습니다.

'랭귀지 > PYTHON' 카테고리의 다른 글

python pip 특정 버전설치 및 설치  (0) 2020.02.03
No module named 'PyQt5.QtWebEngineWidgets'  (0) 2019.12.23
장고프레임워크 설치  (0) 2019.10.27
[python] 설치된 package 버전 확인  (0) 2019.10.02
HTTP Request with Python  (0) 2019.09.09
Comments