python selenium如何实现重复执行登陆系统,退出系统的代码

Python012

python selenium如何实现重复执行登陆系统,退出系统的代码,第1张

count=0

while True: 

//登录、退出代码

    count+=1

    if count>=10: //重复10次停止运行

        break

# -*- coding:utf-8 -*-

#! python2

import wmi

def sys_version(ipaddress, user, password):

conn = wmi.WMI(computer=ipaddress, user=user, password=password)

for sys in conn.Win32_OperatingSystem():

print "Version:%s" % sys.Caption.encode("UTF8"),"Vernum:%s" % sys.BuildNumber #系统信息

print sys.OSArchitecture.encode("UTF8") # 系统的位数

print sys.NumberOfProcesses # 系统的进程数

if __name__ == '__main__':

sys_version(ipaddress="ip", user="用户名", password="密码")

代码:

#!/usr/bin/expect -f

set password 12345678

spawn ssh name@###.###.###

expect {

"*(yes/no)?" { send "yes\r"exp_continue }

"name@###.###.###'s password:" { send "$password\r" }

}

expect "$*"

interact