pythonフォームのコミットとjsonのコミット
1476 ワード
pythonコミットフォーム
pythonコミットjson
#!/usr/bin/python
# -*- coding:utf-8 -*-
import httplib,urllib,json;
def SendRedPacket():
params = urllib.urlencode({'count':'100', 'amount':'6666', });
headerdata = {
"Content-type": "application/x-www-form-urlencoded; charset=UTF-8",
"Cookie": "4&_token=12410&d23272107;4&_dev=iP6197F&6.3.15"
}
conn = httplib.HTTPConnection("mobile.test.XXXXXXX.com");
conn.request(method="POST",url="https://mobile.test.XXXXXXX.com/send",body=params,headers=headerdata);
response = conn.getresponse();
print("status:%d"%response.status)
print("content:%s"%response.read())
conn.close();
pythonコミットjson
import httplib
import cookielib
def sendRedPacket():
test_data = {'count':'100','amount':'100'}
requrl = "https://mobile.test.xxxxxxxxxx.com/send"
headerdata = {
#"Content-type": "application/json",
"Content-type": "application/x-www-form-urlencoded",
"Cookie": "4&_token=13272107;4&_dev=iPh&6.3.15"
}
conn = httplib.HTTPConnection("mobile.test.xxxxxxxx.com")
conn.request('POST',requrl,json.dumps(test_data),headerdata)
response = conn.getresponse()
res= response.read()
print res
conn.close();