使用Invoke-WebRequest显示所有内容 [英] Display all content with Invoke-WebRequest

查看:532
本文介绍了使用Invoke-WebRequest显示所有内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我决定开始使用PowerShell,而不是命令提示符。我想运行 curl 。然后非常不同的输出发现 curl 是PowerShell中 Invoke-WebRequest 的别名。

So I decided to start using PowerShell rather than Command Prompt. And I want to run curl. Very different output then discover that curl is an alias to Invoke-WebRequest in PowerShell.

使用PowerShell curl 与真正的 curl 相同,

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

我已经看到可以将PowerShell curl 的输出放入变量中,然后使用 $ variable.Content 以显示所有内容,但这似乎比实际的 curl 还要额外。

I have seen that I can put the output of PowerShell curl into a variable and then use $variable.Content to display all of the content but that seems extra work over real curl.

是否可以直接显示所有内容?我看不到帮助中的一个。

Is there an option to show all of the content directly? I can't see one in the help.

推荐答案

curl 命令行实用程序 Invoke-WebRequest 返回具有各种属性的对象,所请求文档的内容仅仅是其中的一种。您可以通过如下扩展属性来在单个语句中获取内容:

Unlike the curl command line utility Invoke-WebRequest returns an object with various properties of which the content of the requested document is just one. You can get the content in a single statement by expanding the property like this:

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

或通过像这样的点符号获取属性值:

or by getting the property value via dot-notation like this:

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






或者,您可以使用Windows端口 卷曲

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

以扩展名调用程序区别于 Invoke-WebRequest 的别名 curl

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

这篇关于使用Invoke-WebRequest显示所有内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆