[命令] Linux 命令 curl (测试网页访问)

内容一:测试网页可以被访问的案例

# curl -v -k https://eternalcenter-may-1-2022.github.io

(补充:这里以直接访问 https://eternalcenter-may-1-2022.github.io 网页为例)

内容二:测试网页访问速度的案例
2.1 案例一:显示测试过程

# curl -o /dev/null -s -w %{http_code}:%{http_connect}:%{content_type}:%{time_namelookup}:%{time_redirect}:%{time_pretransfer}:%{time_connect}:%{time_starttransfer}:%{time_total}:%{speed_download} https://eternalcenter-may-1-2022.github.io

(补充:这里以访问并测试 https://eternalcenter-may-1-2022.github.io,并显示测试过程为例)

2.2 案例二:不显示测试过程

# curl -o /dev/null -w %{http_code}:%{http_connect}:%{content_type}:%{time_namelookup}:%{time_redirect}:%{time_pretransfer}:%{time_connect}:%{time_starttransfer}:%{time_total}:%{speed_download} https://
eternalcenter.com

(补充:这里以访问并测试 https://eternalcenter-may-1-2022.github.io,并不显示测试过程为例)

内容三:测试使用代理访问网页的案例
3.1 案例一:使用代理

# curl -v --proxy proxy.example.com:8080 https://eternalcenter-may-1-2022.github.io

(补充:这里以通过 proxy.example.com:8080 代理访问 https://eternalcenter-may-1-2022.github.io 网页为例)

3.2 案例二:使用代理并使用用户进行验证

# curl -v --<proxy user> user:<password> --proxy proxy.example.com:8080 https://eternalcenter-may-1-2022.github.io

(补充:这里以通过 proxy.example.com:8080 代理并使用 proxy user 和 password 进行验证访问 https://eternalcenter-may-1-2022.github.io 网页为例)

内容四: 测试使用证书访问网页的案例

# curl -v -k https://eternalcenter-may-1-2022.github.io --cacert /eternalcenter.com.pem

(补充:这里以通过 eternalcenter.com.pem 证书访问 https://eternalcenter-may-1-2022.github.io 网页为例)

内容五:其他测试访问网页的案例
5.1 案例一:将网页下载后另存为别的文件

# curl -v -k https://eternalcenter-may-1-2022.github.io -o eternalcentre.com

(补充:这里以下载 https://eternalcenter-may-1-2022.github.io 并另存为 eternalcentre.com 为例)

5.2 案例二:不使用安全策略下载的案例

# curl -v -k https://eternalcenter-may-1-2022.github.io --insecure

(补充:这里以不使用安全策略下载 https://eternalcenter-may-1-2022.github.io)

5.3 案例三:静默下载的案例

# curl -v -k https://eternalcenter-may-1-2022.github.io --silent

(补充:这里以静默下载 https://eternalcenter-may-1-2022.github.io 为例)