国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python client使用http post 到server端的代碼

2019-11-25 18:41:11
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

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")
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 临沂市| 集贤县| 绥棱县| 桃园县| 策勒县| 佛坪县| 化德县| 鲁山县| 宣汉县| 鄯善县| 大荔县| 河北省| 辛集市| 山阳县| 绵竹市| 伊宁县| 垫江县| 南漳县| 浦江县| 东城区| 富宁县| 邹平县| 白城市| 个旧市| 新平| 远安县| 凉城县| 宁化县| 黄陵县| 竹北市| 英超| 乌拉特前旗| 托里县| 泽库县| 青海省| 三穗县| 荥阳市| 横山县| 平泉县| 胶州市| 旌德县|