python client使用http post 到server端的代码
2013-02-10 00:00
781 查看
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 client使用 http post 到server端
- HttpClient使用之模拟登录人人网(Post请求)
- java之HttpClient 使用[get/post]
- HttpClient使用Post和Get提交参数 中文乱码处理
- HttpClient通过Post上传文件的实例代码
- Simple HTTP Server and Client in Python
- 【C/S通信交互之Http篇】Cocos2dx(Client)使用Curl与Jetty(Server)实现手机网游Http通信框架(内含解决curl.h头文件找不到问题)
- Python使用Socket(Https)Post登录百度的实现代码
- python3.x 使用http-post方式调用webservice
- JAVA Httpclient3.x与Httpclient4.x代码对比(post方法)
- HttpClient4.x进行Get/Post请求并使用ResponseHandler处理响应
- python实现的udp协议Server和Client代码实例
- Python: http查询(GET,POST)简单代码
- HttpClient 4.1.3 初学篇---使用Get和Post模拟登录简单页面(分别带参数)
- Android系列之网络(三)----使用HttpClient发送HTTP请求(分别通过GET和POST方法发送数据)
- Simple HTTP Server and Client in Python
- write a python http server & client
- 记录 boost 中 使用 asio 编写 server和client代码片段
- Simple HTTP Server and Client in Python