Skip to content

Instantly share code, notes, and snippets.

@sky-joker
Created May 7, 2017 09:41
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/44037aa813a3aafc1ecdb9a59f293e9a to your computer and use it in GitHub Desktop.
Save sky-joker/44037aa813a3aafc1ecdb9a59f293e9a to your computer and use it in GitHub Desktop.
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