Linux curl 命令


#Linux#


安装 curl

Ubuntu:

$ sudo apt-get update
$ sudo apt-get install curl

查看网页内容

$ curl http://www.qq.com
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>stgw/1.3.10.9_1.13.5</center>
</body>
</html>

查看网页内容,以及 HTTP 请求头、响应头

$ curl -v http://www.qq.com
* Rebuilt URL to: http://www.qq.com/
*   Trying 58.250.137.36...
* Connected to www.qq.com (58.250.137.36) port 80 (#0)
> GET / HTTP/1.1
> Host: www.qq.com
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 302 Moved Temporarily
< Server: stgw/1.3.10.9_1.13.5
< Date: Sat, 22 Jun 2019 09:57:59 GMT
< Content-Type: text/html
< Content-Length: 169
< Connection: keep-alive
< Location: https://www.qq.com/
<
<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>stgw/1.3.10.9_1.13.5</center>
</body>
</html>
* Connection #0 to host www.qq.com left intact

( 本文完 )