Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 840
Mariusz Pawelski Avatar asked Sep 04 '12 11:09

Mariusz Pawelski


1 Answers

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.

like image 194
Chris N Avatar answered Oct 15 '22 21:10

Chris N