python client使用http post 到server端的代碼
更新時(shí)間:2013年02月10日 17:44:24 作者:
python client使用 http post 到server端的代碼,供大家學(xué)習(xí)參考
復(fù)制代碼 代碼如下:
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")
您可能感興趣的文章:
- PHP中soap用法示例【SoapServer服務(wù)端與SoapClient客戶端編寫】
- Java虛擬機(jī)JVM之server模式與client模式的區(qū)別
- Python Socket實(shí)現(xiàn)簡(jiǎn)單TCP Server/client功能示例
- Android系統(tǒng)進(jìn)程間通信(IPC)機(jī)制Binder中的Server和Client獲得Service Manager接口之路
- python實(shí)現(xiàn)的udp協(xié)議Server和Client代碼實(shí)例
- SQL Server Native Client下載 SQL Server Native Client安裝方法
- 使用Java實(shí)現(xiàn)簡(jiǎn)單的server/client回顯功能的方法介紹
- Asp.Net 不同的OnClick事件區(qū)別小結(jié)(onserverclick,onclientclick)
- JVM Client和Server端有什么區(qū)別
相關(guān)文章
MAC下Anaconda+Pyspark安裝配置詳細(xì)步驟
一般MAC上使用的是zsh的shell工具,需要修改zshrc文件來使環(huán)境變量永久生效(若不修改該文件,在命令行中輸入相應(yīng)的命令即可,本文給大家介紹MAC下Anaconda+Pyspark安裝配置詳細(xì)步驟,感興趣的朋友跟隨小編一起看看吧2021-12-12python啟動(dòng)應(yīng)用程序和終止應(yīng)用程序的方法
今天小編就為大家分享一篇python啟動(dòng)應(yīng)用程序和終止應(yīng)用程序的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-06-06Python實(shí)現(xiàn)Gif圖片分解的示例代碼
這篇文章主要為大家詳細(xì)介紹了如何利用Python語言實(shí)現(xiàn)Gif圖片分解功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起動(dòng)手嘗試一下2022-08-08Python的凈值數(shù)據(jù)接口調(diào)用示例分享
這篇文章主要介紹了Python的凈值數(shù)據(jù)接口調(diào)用示例分享的相關(guān)資料,需要的朋友可以參考下2016-03-03linux環(huán)境下安裝python虛擬環(huán)境及注意事項(xiàng)
這篇文章主要介紹了linux環(huán)境下安裝python虛擬環(huán)境,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-01-01