`
nanjingjiangbiao_T
  • 浏览: 2604596 次
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

python client使用 http post 到server端

 
阅读更多
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端的代码

    复制代码 代码如下:import urllib, httplib import utils import json class User: def __init__(self): print ‘a’ def login(self, imsi, ua): print “==============user start login==================...

    Python实现基于HTTP文件传输实例

    因为需要最近看了一下通过POST请求传输文件的内容 并且自己写了Server和Client实现了一个简单的机遇HTTP的文件传输工具 二、实现代码: Server端: 复制代码 代码如下:#coding=utf-8 from BaseHTTPServer import ...

    python http 服务端客户端

    Python中可以使用http.server模块来实现简单的HTTP服务端和客户端。 HTTP服务端: 导入相关库:首先需要导入http.server模块。 创建HTTP请求处理类:创建一个继承自http.server.BaseHTTPRequestHandler的子类,...

    jsonrpc-client:另一个 python json-rpc 客户端

    jsonrpc-client 使用 requests 来发出请求,你可以将 requests.post 的任何参数传递给 jsoncliet.Client >> from jsonclient import Client >> headers = {"token":"xxxooo"} >> rpc_client = Client(...

    MantleOfSaturn:Mantle Of Saturn是基于PHP Server和Python Client的远程管理工具

    此远程管理工具使用POST&READ方法,不需要打开端口。 我为基于虚拟Web的OS系统PHP Server建立了逼真的图形设计。 包括一个Betcalculator应用程序作为奖励,并提供了此PHP服务器中更多应用程序的示例。 官方网站: ...

    sseclient:纯Python服务器端事件(SSE)客户端

    适用于Python的服务器端事件(SSE)客户端 SSE事件源的Python客户端与urllib3和requests无缝集成。 安装 $ pip install sseclient-py 用法 import json import pprint import sseclient def with_urllib3 ( url , ...

    Python-FastCGI-Client:用于Python的FastCGI客户端(直接与fastcgi-server(例如PHP-FPM等)进行通信)注意

    如何使用?(您应该开始FastCGI流程) from FastCGIClient import * client = FastCGIClient('127.0.0.1', 9000, 3000, 0) params = dict() documentRoot = "/Users/baidu/php_workspace" uri = "/echo.php" ...

    Python程序设计(第二版).chm

    A Simple Python File Server Chapter 11. Client-Side Scripting Section 11.1. "Socket to Me!" Section 11.2. Transferring Files over the Net Section 11.3. Processing Internet Email Section ...

    python suds访问webservice服务实现

     在Python3环境下如果使用:pip install suds,应该会报ImportError: No module named client,这里推荐安装suds-py3。 使用 1.获取所有方法 webservice中的方法,跟http中的get、post这种类似。 from suds....

    Python用GET方法上传文件

    这就是用Get上传文件的例子,client用来发Get请求,server用来收请求。文件内容是在http请求的body内传过去的。用了不同的语言,因为我觉得各自处理起来都要方便些。而且我觉得浏览器也是可以发出这样的请求的,之后...

    Server-Client-appllication

    服务器应该能够执行以下操作:•接受多个连接请求•维护一个适当的数据结构(“注释”字典或面板),以保存从客户端接收到的数据•处理从客户端接收到的消息:o如果消息为POST,则服务器将必须存储消息中描述的注释...

    Realtime-Logger:通过Websocket,Nodejs,SocketIO和Restful API来提供日志的简单轻量级实时日志调试器(PHP,Python ...)

    实时记录仪通过Websocket...安装必需:Nodejs,服务器上可用的端口8080(可以在server.js源代码和客户端javascript中进行更改)如果不使用localhost,则可以在socketserver / server.js,socketclient / index.html,pu

    基于字符级卷积神经的中文情感分析算法源码+项目说明.zip

    使用ip:8000/predict是post的地址,使用python C-CNN-SA-client.py即可模拟请求,注意模型第一次初始化的时间因为需要加载预训练模型,推理速度有些慢,目前单机单线曾运行的正常推理速度在100ms之内,多进程部署会...

    gvim 7.4.110 for Windows 64 位,带 +lua 及 Lua 库(开箱即用)

    +clientserver -footer +persistent_undo +title +clipboard +gettext/dyn -postscript -toolbar +cmdline_compl -hangul_input +printer +user_commands +cmdline_hist +iconv/dyn +profile +vertsplit +cmdline_...

    api:与NPO前端API对话的脚本。 可用的客户包括bash,perl,php,python和ruby

    michiel@baleno: ~ /github/npo-poms/api/bash/publish$ ./post.sh ../publish-examples/page-withembeds.xml http://localhost:8060/api/pages/updates HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: ...

    google-protorpc:http的镜像

    只需通过运行以下命令在端口 8000 上启动服务器: python demo/server.py在另一个终端中,您可以使用以下命令运行客户端: python demo/client.pyAPI 也可以通过 JSON POST 访问: curl -H 'content-type:...

    gvim 7.4.110 for Windows 32 位,带 +lua 及 Lua 库(开箱即用)

    +clientserver -footer +persistent_undo +title +clipboard +gettext/dyn -postscript -toolbar +cmdline_compl -hangul_input +printer +user_commands +cmdline_hist +iconv/dyn +profile +vertsplit +cmdline_...

    带lua支持的gvim编辑器

    +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra...

    sqlmap (懂的入)

    python sqlmap.py -u "http://192.168.1.47/page.php" --method "POST" -- data "id=1&cat=2" 6、指定cookie,可以注入一些需要登录的地址 python sqlmap.py -u ...

    GVim 7.2.441

    +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +...

Global site tag (gtag.js) - Google Analytics