手机
当前位置:查字典教程网 >脚本专栏 >python >python client使用http post 到server端的代码
python client使用http post 到server端的代码
摘要:复制代码代码如下:importurllib,httplibimportutilsimportjsonclassUser:def__init_...

复制代码 代码如下:

import urllib, httplib

import utils

import json

class User:

def __init__(self):

print 'a'

def login(self, imsi, ua):

print "==============user start login=================="

input = {

"method" : "user.login",

"userName" : "",

"userPass" : "",

}

input["sig"] = utils.getSignature(input)

params = urllib.urlencode(input)

headers = {

"user-agent" : ua,

"Appstore-clientType" : "android",

"Appstore-IMEI" : "123456789000000",

"Appstore-IMSI" : imsi

}

try:

connection = httplib.HTTPConnection(utils.API_HOST)

connection.request("POST", "/api", params, headers)

response = connection.getresponse().read()

#print "=========" + response

connection.close()

except Exception, e :

print "========" + str(e)

if "errorcode" in response or response is None:

return

results = json.loads(response)

return results["results"].encode("utf-8")

【python client使用http post 到server端的代码】相关文章:

Python translator使用实例

python 生成不重复的随机数的代码

分析python服务器拒绝服务攻击代码

python 不关闭控制台的实现方法

python调用cmd复制文件代码分享

python判断端口是否打开的实现代码

Python群发邮件实例代码

Python urlopen 使用小示例

Python splitlines使用技巧

Python下singleton模式的实现方法

精品推荐
分类导航