0
Я пытаюсь написать сценарий PowerShell, чтобы открыть окно в хроме, перейти в Google, ввести текст в строке поиска, нажать enter и затем получить все ссылки в массиве. Вот моя первая попытка на код:Сценарий для открытия веб-страницы и поиска
$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
На реальном сайте, вам нужно сделать получить или должность ? –