python3.6发送post请求

参考:【python】3.6版本使用http.client网络请求示例

#!/user/bin/python
#-*- coding:utf-8 -*-

import urllib.parse
import http.client
import json

test_data ={'uid':55,'page':1}  
test_data_url_encode = urllib.parse.urlencode(test_data)
request_url = "http://m.mp.oeeee.com/uncache.php?m=Doc&a=spaceInfo"
conn = http.client.HTTPConnection('m.mp.oeeee.com')
header = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn.request(method="POST", url=request_url, headers=header, body=test_data_url_encode)
response = conn.getresponse()
#print(response.status)
#print(response.reason)
res = response.read()
#print(res)
resp = json.loads(res)
print(resp)
    原文作者:波子汽水yeah
    原文地址: https://blog.csdn.net/maobois/article/details/79379307
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞