使用urllib2发起post请求
def GetCsspToken():
data = json.dumps({"userName":"wenbin", "password":"passwd"})
try:
req = urllib2.Request('http:9.123.127.9/api/system/login', data, {'Content-Type':'application/json'})
f = urllib2.urlopen(req)
response = f.read()
f.close()
except urllib2.URLError, e:
print e
try:
return json.loads(response)["entity"]["tokenId"]
except:
return ""