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

I load a site with this command:

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

Can I use querySelector or querySelectorAll to find specific items? I know that I can use $response.ParsedHtml.all and filter them, but I want to use a more complex query and I don’t see anything in $response.ParsedHtml.documentElement .

I am using powershell 3 RC.

+4
source share
1 answer

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

 $response.ParsedHtml.getElementsByTagName("img") 

There are other methods for a class name or identifier. Use $response.ParsedHtml | gm -MemberType Method $response.ParsedHtml | gm -MemberType Method for more options.

+2
source

Source: https://habr.com/ru/post/1432256/


All Articles