Show all content with Invoke-WebRequest

So I decided to start using PowerShell, not Command Prompt. And I want to run curl . A very excellent result, then find that curl is an alias of Invoke-WebRequest in PowerShell.

Using PowerShell curl in the same way as real curl , I get only part of the displayed content.

I saw that I can put the PowerShell curl output into a variable and then use $variable.Content to display all the content, but this seems like extra work on the real curl .

Is it possible to display all content directly? I do not see him in the help.

+6
source share
3 answers

Unlike curl Invoke-WebRequest command-line utility returns an object with various properties whose contents of the requested document are only one, you can get the contents in one statement by expanding the property as follows:

 Invoke-WebRequest 'http://www.example.org/' | Select-Object -Expand Content 

or by getting the value of a property through a dotted record as follows:

 (Invoke-WebRequest 'http://www.example.org/').Content 

Alternatively, you can use the Windows curl port:

 & curl.exe 'http://www.example.org/' 

Call the program with the extension to distinguish it from the curl alias for Invoke-WebRequest .

+11
source

Something like that?

 $res=Invoke-WebRequest "https://www.google.fr/" #for look html of body $res.ParsedHtml.body.innerHTML #for look text of body $res.ParsedHtml.body.innerText 
0
source

Well, if you are worried about extra typing, this is the shortest way to achieve this (well, at least I can think of):

 (iwr google.tt).content 
0
source

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


All Articles