這是代碼:
$ie = New-Object -ComObject 'InternetExplorer.Application'
$ie.Visible= $true # Make it visible
$username="[email protected]"/span>
$password="MyPassword"。
$ie.Navigate("https://service.post.ch/zopa/dlc/app/?service=dlc-web&inMobileApp=false&inIframe=false&lang=fr#! /main")
While ($ie.Busy -eq $true) {Start-Sleep -Seconds 3; }
$usernamefield = $ie.document.getElementByID('isiwebuserid')
$usernamefield.value = "$username"。
$passwordfield = $ie.document.getElementByID('isiwebpasswd')
$passwordfield.value = "$password"。
$Link = $ie.document.getElementByID('actionLogin')
$Link.click()
while($ieobject.Busy) { Start-Sleep -seconds 10 }
$ie.Quit()
正如你從視頻中看到的,網站post.ch打開了,但隨后視窗關閉了,即使我在$ie.Quit()之前設定了Start-Sleep -seconds 10。
這讓我覺得腳本可能在作業,但不確定在下一頁會發生什么。
瀏覽器就這樣關閉了。
有什么想法嗎?
你知道這是怎么回事嗎?
你也可以創建自己的網站。
如果你想測驗,你也可以在該網站上創建一個帳戶。
錯誤說:
Exception from HRESULT: 0x800A01B6
在C:UsersfmvDesktopImport Ref Data scriptsgetPosteDataUAT.ps1:12 char:1
$usernamefield = $ie.document.getElementByID('isiwebuserid')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : OperationStopped: (:) [], NotSupportedException
FullyQualifiedErrorId : System.NotSupportedException
在這個'value'上找不到屬性object。驗證該屬性是否存在和可以被設定。
在C:UsersfmvDesktopImport Ref Data scriptsgetPosteDataUAT.ps1:13 char:1
$usernamefield.value = "$username"。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidOperation: (:) [], 運行時例外。
FullyQualifiedErrorId : PropertyNotFound
Exception from HRESULT。0x800A01B6
在C:UsersfmvDesktopImport Ref Data scriptsgetPosteDataUAT.ps1:15 char:1
$passwordfield = $ie.document.getElementByID('isiwebpasswd')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : OperationStopped: (:) [], NotSupportedException
FullyQualifiedErrorId : System.NotSupportedException
在這個'value'上找不到屬性object。驗證該屬性是否存在和可以被設定。
在C:UsersfmvDesktopImport Ref Data scriptsgetPosteDataUAT.ps1:16 char:1
$passwordfield.value = "$password"。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidOperation: (:) [], 運行時例外。
FullyQualifiedErrorId : PropertyNotFound
Exception from HRESULT: 0x800A01B6
在C:UsersfmvDesktopImport Ref Data scriptsgetPosteDataUAT.ps1:18 char:1
$Link = $ie.document.getElementByID('actionLogin')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : OperationStopped: (:) [], NotSupportedException
FullyQualifiedErrorId : System.NotSupportedException
你不能在一個null值的運算式上呼叫一個方法。
在C:UsersfmvDesktopImport Ref Data scriptsgetPosteDataUAT.ps1:19 char:1
$Link.click()
~~~~~~~~~~~~~
CategoryInfo : InvalidOperation: (:) [], 運行時例外。
FullyQualifiedErrorId : InvokeMethodOnNull
uj5u.com熱心網友回復:
While ($ie.Busy -eq $true)不是一個有效的方法來等待一個網站被加載。不幸的是,沒有標準的方法來告訴一個網站已經完全加載。Javascript可以在稍后的任何時間加載東西,或者永久地加載。
所以你必須自己定義你的 "完全加載 "狀態。例如,您可以等到某個元素的存在。
除此之外,看起來該網站在 IE 中根本就沒有加載。因此,這些元素在這個瀏覽器中永遠無法使用(至少在我的機器上)。不過,它在 Edge 和 Firefox 中可以使用。
如果網站在你的IE中加載,你可以用While ($ie.Busy -eq $true) ...代替,只用Start-Sleep -Seconds 10。這樣,你肯定會等待10秒。這應該足以讓元素加載(如果它們真的加載的話)。而且錯誤也應該消失了。如果這行得通,請尋找一個更好的方法來等待。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/320183.html
標籤:
上一篇:突變以合并R中不同df的最小值

