Skip to content

Instantly share code, notes, and snippets.

@sky-joker
Created May 7, 2017 09:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sky-joker/3a56afa0c169a4e2e068805088bda4c4 to your computer and use it in GitHub Desktop.
Save sky-joker/3a56afa0c169a4e2e068805088bda4c4 to your computer and use it in GitHub Desktop.
requestモジュールで実行
#!/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