无法使用PowerShell登录网站

时间:2017-10-10 09:50:16

标签: html powershell

我正在尝试自动登录网站,但它对我不起作用。可能是由于嵌套的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

0 个答案:

没有答案
相关问题