python 登录ELK脚本

python 登录ELK脚本

#!/usr/bin/env python
#coding:utf-8

import urllib2
test = “hello world”

password = “1234@DJ”

webserver = “xx.xx.xx.xx”

#构建一个密码管理对象,可以用来保存和http请求相关的授权账户信息
passwordMgr = urllib2.HTTPPasswordMgrWithDefaultRealm()

#添加授权账户信息,第一个参数realm如果没有指定就写None,后三个分别是站点IP,账户和密码
passwordMgr.add_password(None,webserver, test, password)

httpauth_handler = urllib2.HTTPBasicAuthHandler(passwordMgr)

opener = urllib2.build_opener(httpauth_handler)

request = urllib2.Request(“http://xx.xx.xx.xx/app/kibana”)
response = opener.open(request)

#response = urllib2.urlopen(request)

print response.read()

你可能感兴趣的:(python,ELK)