Curl: Command line access to Web pages, websites, download files
[[email protected] ~]# Curl www.apelearn.com #这个命令之后, there are a lot of www.apelearn.com website source code
[[email protected] ~]# curl-i!$-I omit source
Curl-i www.apelearn.com
http/1.1 OK
Server:nginx
date:wed, 15:16:31 GMT
Content-type:text/html
Connection:keep-alive
Vary:accept-encoding
x-powered-by:php/5.3.27
Note that there is a K OK, in fact, the common status code is also 200 301 302 404 403 502 503
-----------------------------------------------------------------------------------
[[email protected] ~]# curl-i www.lishiming.net Curl a bit this site found a status code of 301, which means set a jump
http/1.1 301 Moved Permanently
server:nginx/1.0.15
date:wed, 15:23:44 GMT
Content-type:text/html
content-length:185
Connection:keep-alive
location:http://www.apelearn.com/bbs/forum.php #跳转到这个域名下.
[Email protected] ~]#
--------------------------------------------------------------------------------------
[Email protected] ~]# vim/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.1 www.qq.com
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/hosts" 3L, 181C
[[email protected] ~]# Ping www.qq.com
PING www.qq.com (192.168.1.1) bytes of data.
---------------------------------------------------------------------------
[[email protected] ~]# Ping www.qq.com
PING www.qq.com (220.181.138.29) bytes of data.
Bytes from 220.181.138.29:icmp_seq=1 ttl=128 time=78.3 ms
Bytes from 220.181.138.29:icmp_seq=2 ttl=128 time=77.5 ms
Bytes from 220.181.138.29:icmp_seq=3 ttl=128 time=83.9 ms
Bytes from 220.181.138.29:icmp_seq=4 ttl=128 time=87.4 ms
Bytes from 220.181.138.29:icmp_seq=5 ttl=128 time=77.2 ms
Bytes from 220.181.138.29:icmp_seq=6 ttl=128 time=77.6 ms
^z
[4]+ Stopped Ping www.qq.com
[Email protected] ~]#
--------------------------------------------------------------------------------
Glinux ~]# curl-x220.181.138.29:80 Www.qq.com-I #通过-x command to ping the correct address even if the configuration file is modified, don't forget Add I omit information
http/1.1 OK
server:squid/3.4.3
date:wed, 15:32:12 GMT
content-type:text/html; charset=gb2312
Connection:keep-alive
Vary:accept-encoding
Vary:accept-encoding
expires:wed, 15:33:12 GMT
Cache-control:max-age=60
Vary:accept-encoding
Vary:accept-encoding
X-cache:hit from beijing.qq.com
----------------------------------------------------------------------------------
[Email protected] ~]# curl-iv www.qq.com #显示访问过程.
Curl 7.19.7 (I386-REDHAT-LINUX-GNU) libcurl/7.19.7 nss/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols:tftp ftp telnet dict ldap ldaps http file https FTPs SCP sftp
Features:gss-negotiate IDN IPv6 largefile NTLM SSL libz
-----------------------------------------------------------------------------------
[Email protected] ~]# Curl-iv www.qq.com
* About-to-connect () to www.qq.com Port (#0)
* Trying 220.181.138.29 ... Connected
* Connected to Www.qq.com (220.181.138.29) port (#0)
> head/http/1.1
> user-agent:curl/7.19.7 (I386-REDHAT-LINUX-GNU) libcurl/7.19.7 nss/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host:www.qq.com
> Accept: */*
>
< http/1.1 OK
http/1.1 OK
< server:squid/3.4.3
server:squid/3.4.3
< date:wed, 15:45:45 GMT
date:wed, 15:45:45 GMT
< content-type:text/html; charset=gb2312
content-type:text/html; charset=gb2312
< connection:keep-alive
Connection:keep-alive
< vary:accept-encoding
Vary:accept-encoding
< vary:accept-encoding
Vary:accept-encoding
< expires:wed, 15:46:45 GMT
expires:wed, 15:46:45 GMT
< cache-control:max-age=60
Cache-control:max-age=60
< vary:accept-encoding
Vary:accept-encoding
< vary:accept-encoding
Vary:accept-encoding
< X-cache:hit from beijing.qq.com
X-cache:hit from beijing.qq.com
* No chunk, no close, no size. Assume close to signal end
<
* Closing Connection #0
UserAgent marks, each site has its own logo.
-------------------------------------------------------------------------------
[[email protected] ~]# curl-u username:password http://www.qq.com ^c Specify user access to the site
[[email protected] ~]# curl-u Username:password Http://www.qq.com-I Of course you can add-I, brief information.
http/1.1 OK
server:squid/3.4.3
date:wed, 15:52:13 GMT
content-type:text/html; charset=gb2312
Connection:keep-alive
Vary:accept-encoding
Vary:accept-encoding
expires:wed, 15:53:13 GMT
Cache-control:max-age=60
Vary:accept-encoding
Vary:accept-encoding
X-cache:hit from beijing.qq.com
---------------------------------------------------------------------------------
[Email protected] ~]# Curl-o http://passport.ixpub.net/data/avatar/016/72/81/39_avatar_middle.jpg The last section is the default name, with the Consistent-Large o cannot specify name, rename.
% total% Received% xferd Average speed Time Time current
Dload Upload Total spent
100 5725 100 5725 0 0 1060 0 0:00:05 0:00:05--:--:--35559
[[email protected] ~]# ls 39_avatar_middle.jpg
39_avatar_middle.jpg
[Email protected] ~]# Curl-o Xiazai http://passport.ixpub.net/data/avatar/016/72/81/39_avatar_middle.jp #- Small o can specify the renamed name.
This article is from the "11075268" blog, please be sure to keep this source http://11085268.blog.51cto.com/11075268/1739404
Linux Curl Command