Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
urllibモジュールで実行
#!/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
You can’t perform that action at this time.