Demand:Python模拟登陆WebSphere Integrated Solutions Console
Solution :
# -*- coding: utf-8 -*-
import requests
# 模拟登陆WAS
userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
header = {
"origin": "https://10.20.10.9:9043",
"Referer": "https://10.20.10.9:9043/ibm/console/logonError.jsp",
'User-Agent': userAgent,
}
def login(account, password):
print ("开始模拟登录")
post_url = "https://10.20.10.9:9043/ibm/console/j_security_check"
account_info = {
"passport": account,
"password": password,
}
r = requests.post(post_url, data=account_info, headers=header,verify=False)
# 无论是否登录成功,状态码一般都是 statusCode = 200
print(r.status_code)
print(r.text)
if __name__ == "__main__":
login("account", "password")