def getToken(self):
user_auth = '{"username": "%s","password": "%s"}' % (self.USERNAME, self.PASSWORD)
b = StringIO.StringIO()
c = pycurl.Curl()
c.setopt(pycurl.URL, "http://api.zoomeye.org/user/login")
c.setopt(pycurl.WRITEFUNCTION, b.write)
c.setopt(pycurl.FOLLOWLOCATION, 1)
c.setopt(pycurl.CUSTOMREQUEST, "POST")
c.setopt(pycurl.POSTFIELDS, user_auth)
c.perform()
ReturnData = json.loads(b.getvalue())
self.API_TOKEN = ReturnData['access_token']
b.close()
c.close()
评论列表
文章目录