curl 命令

查看网站源码

[root@localhost ~]# curl www.baidu.com


只查看网站状态信息

[root@localhost ~]# curl -I www.baidu.com

网站状态一般有:200,301,302,403,404,502,503


下图为状态200

wKioL1Z3wOSSQKNuAACS6wRHJ28653.png

下图为状态301,表示访问www.lishiming.net的时候会跳转到http://www.apelearn.com/bbs/forum.php

wKioL1Z3wUaBjDq_AAA03KUTU30978.png


代理访问

[root@localhost ~]# ping baidu.com -c 3

PING baidu.com (220.181.57.217) 56(84) bytes of data.

64 bytes from 220.181.57.217: icmp_seq=1 ttl=53 time=37.1 ms

64 bytes from 220.181.57.217: icmp_seq=2 ttl=53 time=37.1 ms

64 bytes from 220.181.57.217: icmp_seq=3 ttl=53 time=37.3 ms


--- baidu.com ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2039ms

rtt min/avg/max/mdev = 37.128/37.225/37.359/0.243 ms

[root@localhost ~]# curl -x220.181.57.217:80 www.baidu.com -I

HTTP/1.1 200 OK

Date: Mon, 21 Dec 2015 09:08:47 GMT

Server: Apache

Cache-Control: max-age=86400

Expires: Tue, 22 Dec 2015 09:08:47 GMT

Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT

ETag: "51-4b4c7d90"

Accept-Ranges: bytes

Content-Length: 81

Connection: Keep-Alive

Content-Type: text/html


显示访问过程

[root@localhost ~]# curl -Iv baidu.ocm

wKiom1Z3wmWyZZMQAAB3Vb0hT9U691.png

下载文件,大写O

[root@localhost ~]# curl -O https://www.baidu.com/img/bd_logo1.png

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100  7877  100  7877    0     0   1365      0  0:00:05  0:00:05 --:--:--  549k


下载文件并重命名,小写o

[root@localhost ~]# curl -o my.png https://www.baidu.com/img/bd_logo1.png

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100  7877  100  7877    0     0   1538      0  0:00:05  0:00:05 --:--:--  641k



你可能感兴趣的:(命令,curl)