curl -k -u admin:323232 -X GET http://10.4.33.30:8080/cli/component?active=true
python 模拟:
# !/usr/bin/env python
# -*- coding: utf-8 -*-
import re
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import requests
import ssl
import json
s = requests.session()
s.auth = ('admin', '323232')
print s.headers
url = 'http://10.4.33.30:8080/cli/component?active=true'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0'
}
r = s.get(url, headers=headers,verify=False)
print r.status_code
s= r.content
print s
a=json.loads(s)
print type(a)
for x in a:
for key in x:
if key == 'name':
print(str(key) + ':' + str(x[key]))