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!

4
  • I can't use Invoke-WebRequest to parse the HTML for this because PowerShell version is 3.0. Commented Oct 6, 2015 at 20:42
  • 1
    Possible duplicate of stackoverflow.com/questions/25940510/… (pretty sure my answer there could be modified to use $ie.document.innerhtml and get what you need) Commented Oct 6, 2015 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. Commented Oct 8, 2015 at 17:58
  • Resolved - had to use a higher level <div> tag which had the table nested in order to extract the corresponding td. Commented Oct 30, 2015 at 19:36

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.