urllib

http post

import urllib.request,json
method = 'POST'

content = {}
content['param'] = 'value'

headers = {}
headers['Content-Type'] = "application/json"
url = 'url'
content_json = json.dumps(content,ensure_ascii=False).encode('utf-8')
request = urllib.request.Request(url,content_json,headers,method=method)
with urllib.request.urlopen(request) as res:
    body = res.read().decode('utf-8')

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.