Created
May 7, 2017 09:36
-
-
Save sky-joker/3a56afa0c169a4e2e068805088bda4c4 to your computer and use it in GitHub Desktop.
requestモジュールで実行
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import requests | |
import json | |
# 自己証明書の警告を出力しないようにする | |
from requests.packages.urllib3.exceptions import InsecureRequestWarning | |
requests.packages.urllib3.disable_warnings(InsecureRequestWarning) | |
# URL/ユーザー情報 | |
url = 'https://vROps IP or FQDN/suite-api/api/actiondefinitions' | |
user = 'admin' | |
passwd = 'change me' | |
# ヘッダーの設定 | |
headers = { | |
'Content-Type': 'application/json', | |
'Accept': 'application/json' | |
} | |
# Getリクエスト | |
r = requests.get(url, | |
auth=requests.auth.HTTPBasicAuth( | |
user, | |
passwd), | |
headers=headers, | |
verify=False) | |
# JSONをパース | |
j = json.loads(r.text) | |
# JSONを見やすいように整形 | |
print(json.dumps(j, indent=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment