importrequests
importjson
classTools:
def__init__(self,host=None,scheme=None):
self.host = host
self.scheme = scheme
defapiPostMethod(self, api,payload):
url ="%s://%s/%s"% (self.scheme,self.host, api)
headers = {"Content-Type":"application/x-www-form-urlencoded",
"Accept-Encoding":"gzip",
"User-Agent":"XXXX",
}
r = requests.post(url,headers=headers,data=payload)
returnr.json()
defapiGetMethod(self,api,payload,token):
url ="%s://%s/%s"% (self.scheme,self.host, api,)
headers = {"Content-Type":"text/html;charset=utf-8",
"Accept-Encoding":"gzip",
"User-Agent":"XXXX",
"Cookie":"token=%s"%token,
}
r = requests.get(url,headers=headers,params=payload)
print"runing time"
returnr.json()
if__name__=="__main__":
t = Tools(host="api.myhaowai.com",scheme="http")
r = t.apiGetMethod(api="appsite_api/index/login?"
"devid=75B846BFD9524CD13DF605E437AA9DC0&pcode=021000&pwd=123456&username=18310341518"
"&version=3.5",payload=None,token=None)
token1=r["token"]
printtoken1
tt = t.apiGetMethod(api="api/weixin/get_follow_list?page=1 ",payload=None,token=token1)
printtt