Is it possible to use document.querySelector in Invoke-WebRequest in powershell 3.0?
Asked Answered
B

1

7

I'm downloading website with such command:

$response = Invoke-WebRequest 'http://stackoverflow.com'

Is it possible to use querySelector or querySelectorAll to find certain elements? I know I can use $response.ParsedHtml.all and filter those, but I want to use more sophisticated query and I don't see anything in $response.ParsedHtml.documentElement.

I'm using powershell 3 RC.

Bourassa answered 4/9, 2012 at 11:41 Comment(1)
It does exist now!Spang
S
2

I use the method getElementsByTagName. I'm not sure if that will work for you. Here's how I get the images from the page, using your code above:

$response.ParsedHtml.getElementsByTagName("img")

Other methods exist for class name or ID. Use $response.ParsedHtml | gm -MemberType Method for more options.

Spacious answered 4/9, 2012 at 13:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.