Skip to content

Instantly share code, notes, and snippets.

@nesffer
Created March 15, 2016 00:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nesffer/e658fe491fd01842e760 to your computer and use it in GitHub Desktop.
Save nesffer/e658fe491fd01842e760 to your computer and use it in GitHub Desktop.
파이썬에서 query, header 추가해서 urlopen 사용하기
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'))
@Tolluset
Copy link

감사합니다 덕분에 해결했슴당

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment