파이썬에서 query, header 추가해서 urlopen 사용하기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.parse | |
import urllib.request | |
url = 'http://example.com' | |
values = {'name': 'nesffer', | |
'query': 'python'} | |
headers = {'Content-Type': 'text/plain'} | |
data = urllib.parse.urlencode(values).encode('utf-8') | |
req = urllib.request.Request(url, data, headers) | |
f = urllib.request.urlopen(req) | |
print(f.read().decode('utf-8')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
감사합니다 덕분에 해결했슴당