windows 命令行网页浏览
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4619528/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
command line web browsing
提问by P.Brian.Mackey
Is there a way to perform http commands GET/PUT/SET whatever via a command line in ubuntu or windows xp? Preferably without installing 3rd party products. Being that http is text based I thought it would be alot easier to run in the cmd line.
有没有办法通过ubuntu或windows xp中的命令行执行http命令GET/PUT/SET?最好不安装第 3 方产品。由于 http 是基于文本的,我认为在 cmd 行中运行会容易得多。
I've been able to get what I want out of GET in ubuntu in bash via
我已经能够通过 bash 通过 ubuntu 中的 GET 获得我想要的东西
$wget google.com
$cat index.html
This is kinda clunky. It would be nice to pipe the output or something, but even that isn't straight forward. C programs are fine too. I'm trying to do something like what we get with Fiddler, but more basic.
这有点笨拙。管道输出或其他东西会很好,但即使这样也不是直截了当的。C 程序也很好。我正在尝试做一些类似于我们用 Fiddler 得到的东西,但更基本。
采纳答案by Paul Tomblin
telnet google.com 80
GET / HTTP/1.0
Host: google.com
You have to hit return twice after the Host line. It doesn't get any more basic.
您必须在 Host 行之后按回车两次。它没有变得更基本。
回答by Raphael Bossek
回答by P.Brian.Mackey
Although it requires a 3rd party tool, these days I use curl. The -X optionallows me to specify the HTTP verb. Windows has a few bash clients that allow you to run curl including Cygwin.
虽然它需要一个 3rd 方工具,但现在我使用curl。该-X选项让我指定HTTP动词。Windows 有一些 bash 客户端,允许您运行 curl ,包括Cygwin。
Sample Execution
示例执行
$ curl -H "Content-Type: application/json" -X POST -d '{value: "600"}' http://localhost:8888/my/endpoint
$ curl -H "Content-Type: application/json" -X POST -d '{value: "600"}' http://localhost:8888/my/endpoint