Linux curl 命令
v --verbose 可以跟踪URL的连接信息。我们可以根据这个选项看看curl是怎么工作的。
[root@ebs-26562 ~]# curl -v https://yhxt.80899999.cn/
* About to connect() to yhxt.80899999.cn port 443 (#0)
* Trying 218.6.173.111...
* Connected to yhxt.80899999.cn (218.6.173.111) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
* Server certificate:
* subject: CN=yhxt.80899999.cn #证书日期.
* start date: 5月 05 00:00:00 2022 GMT
* expire date: 5月 05 23:59:59 2023 GMT
* common name: yhxt.80899999.cn
* issuer: CN=TrustAsia RSA DV TLS CA G2,O="TrustAsia Technologies, Inc.",C=CN
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: yhxt.80899999.cn
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Server: nginx
< Date: Tue, 17 May 2022 07:57:32 GMT
< Content-Type: text/html
< Content-Length: 162
< Connection: keep-alive
<
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host yhxt.80899999.cn left intact
-u 选项,带用户验证的连接。可以访问或获取带用户验证的URL.
curl -u username:password ftp://ip/tt.txt
-d 选项,带请求参数的连接。比如下面的URL,user=xiaoruan&age=22就是所带的参数。crul可以带请求参数。
http://127.0.0.1/index.html?user=xiaoruan&age=22
curl -d ' user=xiaoruan&age=22' http://127.0.0.1/index.html
-O 选项 下载文件,必须指定文件名.
curl -O https://www.baidu.com/index.html