0
私はChromeでウィンドウを開き、googleに移動し、検索バーにテキストを入力してEnterキーを押し、配列内のすべてのリンクを取得するPowerShellスクリプトを作成しようとしています。ここでは、コードでの私の最初の試みです:スクリプトを使用してWebページと検索を開く
$URI = "www.google.com"
$HTML = Invoke-WebRequest -Uri $URI
$SearchField = $HTML.ParsedHtml.getElementById('lst-ib')
$SearchField.value = "green flowers"
$SearchButton = $HTML.ParsedHtml.getElementsByName('btnK')
$SearchButton.click();
//Grab links and store into array
は、しかし、私はそれを実行しようとすると、私はこれを取得:本物のサイトで
The property 'value' cannot be found on this object. Verify that the property exists and can be set. At line:4 char:1 + $SearchField.value = "green flowers" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyAssignmentException Method invocation failed because [System.DBNull] does not contain a method named 'click'. At line:6 char:1 + $SearchButton.click(); + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : MethodNotFound
を、あなたは、GETまたはPOSTを実行する必要があります? –