I am trying to collect Total Pages Printed
from a printer's web page. The script can...
However, I don't know how to adjust the script to only capture the numbers I need.
$R=Invoke-WebRequest http://1.2.3.4/status.html -SessionVariable session1
#B553 - name w Html
$R.Forms[0].Fields["B553"]="login"
$R.Forms[0].Fields["password"]="password"
$Invoke1=Invoke-WebRequest -Uri ("http://1.2.3.4/status.html" + $R.Forms[0].Action) -WebSession $session1 -Method POST -Body $R.Forms[0].Fields
Start-Sleep -s 5
$Invoke2=Invoke-WebRequest 'http://1.2.3.4/Maintance-sub-page' -WebSession $session1
$Invoke2.AllElements | where tagname -EQ "dd" | Select innerText
The result of the following:
$Invoke2.AllElements | where tagname -EQ "dd" | Select innerText
It looks like the results in Powershell are in the same order as those on the HTML page. It looks kind of like those results are an array, and (if I counted right), it looks like the field you want is 23 (the array starts at 0).
Give the following a try...
$($Invoke2.AllElements | where tagname -EQ "dd" | Select innerText)[23]