Html Powershell:无法对空值表达式错误调用方法

Html Powershell:无法对空值表达式错误调用方法,html,internet-explorer,powershell,form-submit,powershell-3.0,Html,Internet Explorer,Powershell,Form Submit,Powershell 3.0,我正在尝试通过powershell登录到一个网站 这是PS代码 $username = "userhere" $password = "passhere" $ie = New-Object -com InternetExplorer.Application $ie.visible=$false $ie.navigate("http://www.desistream.tv/en/login.shtml") while($ie.ReadyState -ne 4) {start-sleep -m 1

我正在尝试通过powershell登录到一个网站

这是PS代码

$username = "userhere" 
$password = "passhere"
$ie = New-Object -com InternetExplorer.Application
$ie.visible=$false
$ie.navigate("http://www.desistream.tv/en/login.shtml")
while($ie.ReadyState -ne 4) {start-sleep -m 100}
$ie.document.getElementById("username").value= "$username"
$ie.document.getElementById("pass").value = "$password"
$ie.document.getElementById("loginform").submit()
start-sleep 20
$ie.Document.body | Out-File -FilePath c:\web.txt
这是我运行脚本时遇到的错误。

PS C:\Users\myname\Desktop> .\new.ps1
You cannot call a method on a null-valued expression.
At C:\Users\myname\Desktop\new.ps1:9 char:1
+ $ie.document.getElementById("loginform").submit()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

PS C:\Users\myname\Desktop> http://www.desistream.tv/en/index.shtml

该页面没有ID为“loginform”的元素。

该页面没有ID为“loginform”的元素。

我制作了
IE visible=true
并看到了这一情况。它会在文本框中填写用户名和密码,但它没有点击提交。我制作了
IE visible=true
,看到了这一点。它会在文本框中填写用户名和密码,但不会单击提交。非常感谢
frmLogin
。现在我相信一切皆有可能。与编程有关。非常感谢
frmLogin
。现在我相信一切皆有可能。与编程有关。