Powershell Web-Request

John T 21 Reputation points
2022-01-10T17:11:53.587+00:00

End Game is to have a variable = zoneval7 but I can't seem to get it. See html below:

163693-html-page-snip.png163694-html-page-snip.png

Windows for business | Windows Server | User experience | PowerShell
{count} votes

Answer accepted by question author
  1. Rich Matheisen 48,026 Reputation points
    2022-01-11T20:34:12.163+00:00

    if you can get the contents of that element inspection into a plain text file, AND you're pretty sure that there's only one table row named "zoneval7 you COULD just use a simple regular expression to extract the value:

    $var = 'undefined'
    if ($html -match '<td id="zoneval7">([^<]+)'){
        $var = $matches[1]
    }
    $var
    

    Otherwise you'd have to load the data into an HTMLDocument COM object and navigate your way down to the correct table and then find the table row.

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Rich Matheisen 48,026 Reputation points
    2022-01-10T19:36:35.37+00:00

    If there's only one TD that has an id of "zoneva17", try this:

    $r.ParsedHTML.GetElementByID('zoneva17')
    

  2. John T 21 Reputation points
    2022-01-11T17:29:46.117+00:00

  3. Rich Matheisen 48,026 Reputation points
    2022-01-11T20:33:25.307+00:00

    f you can get the contents of that element inspection into a plain text file, AND you're pretty sure that there's only one table row named "zoneval7 you COULD just use a simple regular expression to extract the value:

    $var = 'undefined'
    if ($html -match '<td id="zoneval7">([^<]+)'){
        $var = $matches[1]
    }
    $var
    

    Otherwise you'd have to load the data into an HTMLDocument COM object and navigate your way down to the correct table and then find the table row.

    0 comments No comments

  4. John T 21 Reputation points
    2022-01-11T22:46:01.377+00:00

    The device itself stores an xml page that I discovered and used it to solve for it's value. Thanks for your help, I'll try your way as well to see if it works and keep it for future ref thanks.

    164081-image.png

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.