2017-08-07 18 views
0

を閲覧自動化しようとしています。は、私はこのようなHTMLフォームを持っている

しかし
$username='[email protected]' 
$password='<password>' 




$ie = New-Object -ComObject 'internetExplorer.Application' 
$ie.Visible= $true 
$ie.Navigate("https://www.ksl.com/public/member/signin?login_forward=%2F") 


while ($ie.Busy -eq $true){Start-Sleep -seconds 1;} 

$usernamefield = $ie.Document.getElementByID('memberemail') 
$usernamefield.value = $username 

$passwordfield = $ie.Document.getElementByID('memberpassword') 
$passwordfield.value = $password 

$Link=$ie.Document.getElementsByTagName("input") | where-object {$_.className -eq "continue"} 



#<INPUT tabIndex=3 id=Logon onclick=this.disabled=true;this.form.submit(); type=submit value="Sign In"> 
#<input name="ctl00$pageContentPlaceHolder$btnGo" id="ctl00_pageContentPlaceHolder_btnGo" style="width: 200px;" type="submit" value="Sign In"> 


$Link.click() 

私がしようとすると、このようにASP.netページにそれを使用する:

<input name="ctl00$pageContentPlaceHolder$txtUserID" id="ctl00_pageContentPlaceHolder_txtUserID" style="width: 200px;" type="text" maxlength="30" autocomplete="off"> 
<input name="ctl00$pageContentPlaceHolder$txtPassword" id="ctl00_pageContentPlaceHolder_txtPassword" style="width: 200px;" type="password" maxlength="256" autocomplete="off"> 
<input name="ctl00$pageContentPlaceHolder$btnGo" id="ctl00_pageContentPlaceHolder_btnGo" style="width: 200px;" type="submit" value="Sign In"> 

このmodiifiedスクリプトは

ユーザー名とパスワードフィールドを埋めていない
$username='use000' 
$password='<password>' 


$ie = New-Object -ComObject 'internetExplorer.Application' 
$ie.Visible= $true 
#ie.Navigate("https://fasttrng.usask.ca/Login.aspx?ReturnUrl=%2f") 

while ($ie.Busy -eq $true){Start-Sleep -seconds 1;} 

$usernamefield = $ie.Document.getElementByName('ctl00$pageContentPlaceHolder$txtUserID') 
$usernamefield.value = $username 

$passwordfield = $ie.Document.getElementByName('ctl00$pageContentPlaceHolder$txtPassword') 
$passwordfield.value = $password 

$Link=$ie.Document.getElementsByTagName("input") | where-object {$_.id -eq "ctl00_pageContentPlaceHolder_btnGo"} 




$Link.click() 

I取得する

PS C:\Users\rwm132> T:\work\scripts\Untitled4.ps1 

PS C:\Users\rwm132> T:\work\scripts\Untitled4.ps1 

PS C:\Users\rwm132> T:\work\scripts\Untitled5.ps1 
You cannot call a method on a null-valued expression. 
At T:\work\scripts\Untitled5.ps1:11 char:1 
+ $usernamefield = $ie.Document.getElementByName('ctl00$pageContentPlac ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidOperation: (:) [], RuntimeException 
    + FullyQualifiedErrorId : InvokeMethodOnNull 

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 
At T:\work\scripts\Untitled5.ps1:12 char:1 
+ $usernamefield.value = $username 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : OperationStopped: (:) [], COMException 
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException 

You cannot call a method on a null-valued expression. 
At T:\work\scripts\Untitled5.ps1:14 char:1 
+ $passwordfield = $ie.Document.getElementByName('ctl00$pageContentPlac ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidOperation: (:) [], RuntimeException 
    + FullyQualifiedErrorId : InvokeMethodOnNull 

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 
At T:\work\scripts\Untitled5.ps1:15 char:1 
+ $passwordfield.value = $password 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : OperationStopped: (:) [], COMException 
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException 

You cannot call a method on a null-valued expression. 
At T:\work\scripts\Untitled5.ps1:17 char:1 
+ $Link=$ie.Document.getElementsByTagName("input") | where-object {$_.i ... 
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : InvalidOperation: (:) [], RuntimeException 
    + FullyQualifiedErrorId : InvokeMethodOnNull 

The RPC server is unavailable. (Exception from HRESULT: 0x800706BA) 
At T:\work\scripts\Untitled5.ps1:22 char:1 
+ $Link.click() 
+ ~~~~~~~~~~~~~ 
    + CategoryInfo   : OperationStopped: (:) [], COMException 
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException 


PS C:\Users\rwm132> 

ASP.Netレンダリングされた入力フィールドについて特別な何か?

+0

「$」記号をエスケープする必要がありますか?または、なぜあなたは 'getElementByID'から' getElementByName'に変更しましたか? –

+0

はい私はもともとByIDを持っていましたが、どちらも動作しませんでした。これは誰かがこのメソッドがAJAXで動作しないと提案した.NETページです。あなたがname = "ctl00 $ pageContentPlaceHolder $ txtUserID" id = "ctl00_pageContentPlaceHolder_txtUserID"がAJAXページであることを示しているので、sutがわかりません。どういうことだと思いますかJamesZ –

+0

$をエスケープすることはまだ考えていますが、それが問題なのかどうかは分かりませんが、他に何がそんなに悪くなるのか分かりません。 –

答えて

0

このスクリプトはASP.Netではなく静的HTMLで動作しますが、誰かが提示されているAJAXの部分を処理できないと示唆しました。私は.NETの中でこのようなWebフォームが電子であると思った。

+0

私は今、ピトンとセレンを試してみると思います。( – RobM

+0

はいくつかの設定IIS Webサイトでreadystate 4が0から空白に変わることはありませんか? –

関連する問題