【发布时间】:2015-02-02 15:16:00
【问题描述】:
正在努力解决以下问题。
查看 HTML 的摘录,ID 存在,但它一直返回空表达式。不幸的是,我不能在网站上提供更多细节......我做错了什么明显吗?
--- HTML 的提取 ----
<input name="ctl00$mainCopy$LoginView$LoginControl$UserName" type="text" id="ctl00_mainCopy_LoginView_LoginControl_UserName" tabindex="1" class="txtBox" onchange="document.getElementById('ctl00_mainCopy_LoginView_LoginControl_PasswordResetLink').disabled
= false;" style="width:150px;" />
--- 脚本---
$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.navigate("excluded for security")
$ie.document.getElementByID("ctl00_mainCopy_LoginView_LoginControl_UserName").Value= "excluded for security"
---- 错误----
You cannot call a method on a null-valued expression.
At line:1 char:1
+ $ie.document.getElementByID("ctl00_mainCopy_LoginView_LoginControl_UserName").Va ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
【问题讨论】:
标签: internet-explorer powershell web-scraping