python - 远端RESTful API调用
阿神
阿神 2017-04-17 17:50:10
0
4
894
GET /api/accounts HTTP/1.1
Content-Type: application/json
X-Access-Token: username:token

这种 API,Python 要怎么调用啊??
POST 登录生成 token 以后要怎么调用啊??? 求告知

阿神
阿神

闭关修行中......

reply all(4)
PHPzhong
import requests
token = '从你存储的地方取值'
headers = {
    'Content-Type': 'application/json',
    'X-Access-Token': 'username:{0}'.format(token)
}

r = request.get('/api/accounts', headers=headers)
print r.text
洪涛

Save the obtained token locally, and just bring it with you every time you request it

Ty80

import requests

r = requests.get(url)

黄舟

import requests
r = requests.get(url, cookies=cookies)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template