1

Basically, I have a list of server ips ($list). I need to take each of these, go to a web page, enter a search query and press the Search button. Once the search button is pressed, a new table is generated at the bottom of the page which has information about the server. From this, I need the location of the server, which is the second column of the table.

$list = get-content "servers.txt"
$url = "somewebsite.php"

foreach ($item in $list) {
try {
    $ie = New-Object -ComObject InternetExplorer.Application
    $ie.visible = $true 
    $ie.Navigate($url)
    while($ie.Busy){Start-Sleep 1}
    $ie.Document.getElementsByTagName("input") | ? { $_.Name -eq 'ip_address' } | % { $_.value = $item }
    $ie.Document.getElementsByTagName("input") | ? { $_.Value -eq 'search' } | % { $_.Click() }
    while($ie.Busy){Start-Sleep -s 3}

    # $ie.Refresh()
}
catch {
    $_ > error.txt
}

}

The HTML for the newly generated table looks like this: here

Any ideas on how to query the table and get the table data (ORL T)?

Thanks in advance!

rynoknows
  • 93
  • 1
  • 1
  • 8
  • I can't use Invoke-WebRequest to parse the HTML for this because PowerShell version is 3.0. – rynoknows Oct 06 '15 at 20:42
  • 1
    Possible duplicate of http://stackoverflow.com/questions/25940510/how-to-extract-specific-tables-from-html-file-using-native-powershell-commands/ (pretty sure my answer there could be modified to use $ie.document.innerhtml and get what you need) – TheMadTechnician Oct 06 '15 at 20:58
  • I'm not exactly sure how to manipulate it to suit what I need. Basically, I need a txt output file with the second column (just the location) of the table for each server in my list. I believe that'd be the second index of the table. I've tried using .innerHTML and other methods, but can't get it to pull the table from the HMTL. – rynoknows Oct 08 '15 at 17:58
  • Resolved - had to use a higher level
    tag which had the table nested in order to extract the corresponding td.
    – rynoknows Oct 30 '15 at 19:36

0 Answers0