Last updated 4 years ago
1.requests module
methods
reuests.get
reuests.post
reuests.put
reuests.delete
HTTP狀態碼:
https://zh.wikipedia.org/wiki/HTTP%E7%8A%B6%E6%80%81%E7%A0%81
REST API
https://zh.wikipedia.org/wiki/REST
2.Install request module
http://docs.python-requests.org/zh_CN/latest/user/install.html#install
git clone git://github.com/kennethreitz/requests.git python setup.py install
3.GET
1.發送請求
響應內容, JSON響應內容, 狀態碼
2.在header中加入參數
import requests url = 'http://10.144.5.183/api/v1/devices' t = '$2a$10$RqOyphofSoIOwO8mbhEXfOYIX7ZkjrFUyrEPsJ4yzRzvRq/u' h = {'api-token': t} r = requests.get(url, headers=h) print r.text