Created
May 7, 2017 09:41
-
-
Save sky-joker/44037aa813a3aafc1ecdb9a59f293e9a to your computer and use it in GitHub Desktop.
urllibモジュールで実行
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 urllib.request | |
import base64 | |
import ssl | |
import json | |
# 自己証明書の警告を出力しないようにする | |
ssl._create_default_https_context = ssl._create_unverified_context | |
# URL/ユーザー情報 | |
url = 'https://vROps IP or FQDN/suite-api/api/actiondefinitions' | |
user = 'admin' | |
passwd = 'change me' | |
base64string = base64.encodestring(('%s:%s' % (user, passwd)).encode('utf-8'))[:-1] | |
headers = { | |
"Authorization": "Basic %s" % base64string.decode("utf-8"), | |
'Content-Type': 'application/json', | |
'Accept': 'application/json' | |
} | |
req = urllib.request.Request(url, headers=headers) | |
with urllib.request.urlopen(req) as res: | |
html = res.read().decode('utf-8') | |
r = json.loads(html) | |
print(json.dumps(r, indent=2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment