Search Internet Explorer Object

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Dave Wyatt Dave Wyatt 3 years ago.

  • Author
  • #14277
    Profile photo of Seth Burton
    Seth Burton

    I am new to powershell, and am trying to write a script that opens Internet Explorer, navigates to a page, then searches that page for a string of text. Here is the beginning of my code, I just can't seem to figure out how to search the hidden page once it opens for a string of text, such as "EXAMPLE"

    $ie = New-Object -com InternetExplorer.Application
    while($ie.ReadyState -ne 4) {start-sleep -m 100}

    Any help would be greatly appreciated.

  • #14279
    Profile photo of Dave Wyatt
    Dave Wyatt

    Are you fixed on using Internet Explorer for this? You'd have an easier time using Invoke-WebRequest, in PowerShell. For example:

    $response = Invoke-WebRequest -Uri ''

    $response will be a [Microsoft.PowerShell.Commands.HtmlWebResponseObject] object which has lots of useful properties. $response.Content will give you the page's raw HTML code. The AllElements, Forms, Headers, Images, InputFields and Links properties give you access to information about the HTML tags found on the page.

    $response.ParsedHtml will be a reference to a COM object that lets you access the HTML DOM model directly (though I'll warn you, this is very slow in PowerShell for some reason. Use the other properties if they'll get the job done for you.) For instance, you could execute $response.ParsedHtml.documentElement.getElementsByTagName('table')

You must be logged in to reply to this topic.