我正在尝试自动登录网站,但它对我不起作用。可能是由于嵌套的DIV?当我在DOM浏览器中看到它有多个DIV类时,代码以:
开头<form name="aspnetForm" id="aspnetForm" onsubmit="javascript:return WebForm_OnSubmit();"
PS脚本:
$username = "username"
$password = "password"
$IE = New-Object -ComObject "InternetExplorer.Application"
$url = "myurl"
$IE.Visible = $true
$IE.Navigate("$url")
$IE.Document.GetElementById("ctl00_ContentPlaceBody_Login1_UserName").Value = "$username"
$IE.Document.GetElementById("ctl00_ContentPlaceBody_Login1_Password").Value = "$password"
$IE.Document.GetElementById("ctl00_ContentPlaceBody_Login1_ButtonSubmit").Submit();
Start-Sleep -s 5