У меня проблема при попытке войти в следующую HTML-форму с помощью powershell: HTML обновлен, чтобы показать кнопку входа в систему
<tr>
<tr><td align='right' valign=top bgcolor='#ffffff' width=15%><font face='Arial, Helvetica, Verdana' size=-1 color=#000000 id=copy>User name or Email:</font></td><td valign=bottom><input type='text' name=AutoLogin size=30><tr><td align='right' valign=top bgcolor='#ffffff' width=15%><font face='Arial, Helvetica, Verdana' size=-1 color=#000000 id=copy>Password:</font></td><td valign=bottom><input type='password' name=AutoPassword size=30>
</tr></table>
<br>
<table cellpadding=4 cellspacing=1 border=0 bordercolor=#ffffff width=100% height=*>
<tr>
<tr><td><input type=submit value="Log In">
Код powershell для входа на страницу:
& "$env:programfiles\Internet Explorer\iexplore.exe" 'https://login-url.asp'
$win = New-Object -comObject Shell.Application
$try = 0
$ie2 = $null
do {
Start-Sleep -milliseconds 500
$ie2 = @($win.windows() | ? { $_.locationName -like '*Log In*' })[0]
$try ++
if ($try -gt 20) {
Throw "Web Page cannot be opened."
}
} while ($ie2 -eq $null)
$ie2.document
$ie2.Document.body.innerHTML
$doc = $ie2.document
$username = 'xxxxx'
$password = 'xxxxx'
#username field
$usernameField = $doc.getElementsByName("desc")
Write-Host "Username field is?"
$usernameField
#password field
$passwordField = $doc.getElementsByName("password")
Write-Host "Password field is?"
$passwordField
$submitButton = $doc.getElementById('submit')
$submitButton.click()
do {sleep 1} until (-not ($ie2.Busy))