szgzwf

http://www.etsec.com.cn

导航

Linux curl命令

1 常用基本命令    

一 抓取页面内容       curl -o test.html http://www.etsec.com.cn              //获取百度首页源代码,存入test.html文件      

curl -O  curl -O http://www.etsec.com.cn/qqt/index.jsp  //获取获取特定页面,生成新文件index.jsp     二 模拟请求URL       curl -i  http://10.2.164.22:8080/testme/servlet/TestServlet                    //测试url返回包含响应码200       curl -d '<xml><\xml>'   http://10.2.164.22:8080/testme/servlet/TestServlet?user=123//发送xml协议       curl http://10.2.164.22:8080/testme/servlet/TestServlet?user=123               //get方法       curl -d 'user=pp&pass=aa'  http://10.2.164.22:8080/testme/servlet/TestServlet  //post方法     三 下载文件       curl -O http://10.2.164.22:8080/testme/test.jpg                                //下载图片       curl -u 用户名:密码 -O http://www.etsec.com.cn/demo/curtain/bbstudy_files/style.css       curl -T test.sql ftp://用户名:密码@ip:port/demo/curtain/bbstudy_files/         //上传

2. 命令帮助

[plain] view plaincopyprint?
  1. [root@localhost test]# curl --help 
  2. Usage: curl [options...] <url> 
  3. Options: (H) means HTTP/HTTPS only, (F) means FTP only 
  4. -a/--append        Append to target file when uploading (F) 
  5. -A/--user-agent <string> User-Agent to send to server (H) 
  6.     --anyauth       Tell curl to choose authentication method (H) 
  7. -b/--cookie <name=string/file> Cookie string or file to read cookies from (H) 
  8.     --basic         Enable HTTP Basic Authentication (H) 
  9. -B/--use-ascii     Use ASCII/text transfer 
  10. -c/--cookie-jar <file> Write cookies to this file after operation (H) 
  11. -C/--continue-at <offset> Resumed transfer offset 
  12. -d/--data <data>   HTTP POST data (H) 
  13.     --data-ascii <data>   HTTP POST ASCII data (H) 
  14.     --data-binary <data>  HTTP POST binary data (H) 
  15.     --negotiate     Enable HTTP Negotiate Authentication (H) 
  16.     --digest        Enable HTTP Digest Authentication (H) 
  17.     --disable-eprt  Prevent curl from using EPRT or LPRT (F) 
  18.     --disable-epsv  Prevent curl from using EPSV (F) 
  19. -D/--dump-header <file> Write the headers to this file 
  20.     --egd-file <file> EGD socket path for random data (SSL) 
  21.     --tcp-nodelay   Set the TCP_NODELAY option 
  22. -e/--referer       Referer URL (H) 
  23. -E/--cert <cert[:passwd]> Client certificate file and password (SSL) 
  24.     --cert-type <type> Certificate file type (DER/PEM/ENG) (SSL) 
  25.     --key <key>     Private key file name (SSL) 
  26.     --key-type <type> Private key file type (DER/PEM/ENG) (SSL) 
  27.     --pass  <pass>  Pass phrase for the private key (SSL) 
  28.     --engine <eng>  Crypto engine to use (SSL) 
  29.     --cacert <file> CA certificate to verify peer against (SSL) 
  30.     --capath <directory> CA directory (made using c_rehash) to verify 
  31.                     peer against (SSL) 
  32.     --ciphers <list> SSL ciphers to use (SSL) 
  33.     --compressed    Request compressed response (using deflate or gzip) 
  34.     --connect-timeout <seconds> Maximum time allowed for connection 
  35.     --create-dirs   Create necessary local directory hierarchy 
  36.     --crlf          Convert LF to CRLF in upload 
  37. -f/--fail          Fail silently (no output at all) on errors (H) 
  38.     --ftp-create-dirs Create the remote dirs if not present (F) 
  39.     --ftp-pasv      Use PASV instead of PORT (F) 
  40.     --ftp-ssl       Enable SSL/TLS for the ftp transfer (F) 
  41. -F/--form <name=content> Specify HTTP multipart POST data (H) 
  42. -g/--globoff       Disable URL sequences and ranges using {} and [] 
  43. -G/--get           Send the -d data with a HTTP GET (H) 
  44. -h/--help          This help text 
  45. -H/--header <line> Custom header to pass to server (H) 
  46. -i/--include       Include protocol headers in the output (H/F) 
  47. -I/--head          Show document info only 
  48. -j/--junk-session-cookies Ignore session cookies read from file (H) 
  49.     --interface <interface> Specify network interface to use 
  50.     --krb4 <level>  Enable krb4 with specified security level (F) 
  51. -k/--insecure      Allow curl to connect to SSL sites without certs (H) 
  52. -K/--config        Specify which config file to read 
  53. -l/--list-only     List only names of an FTP directory (F) 
  54.     --limit-rate <rate> Limit transfer speed to this rate 
  55. -L/--location      Follow Location: hints (H) 
  56.     --location-trusted Follow Location: and send authentication even  
  57.                     to other hostnames (H) 
  58. -m/--max-time <seconds> Maximum time allowed for the transfer 
  59.     --max-redirs <num> Maximum number of redirects allowed (H) 
  60.     --max-filesize <bytes> Maximum file size to download (H/F) 
  61. -M/--manual        Display the full manual 
  62. -n/--netrc         Must read .netrc for user name and password 
  63.     --netrc-optional Use either .netrc or URL; overrides -n 
  64.     --ntlm          Enable HTTP NTLM authentication (H) 
  65. -N/--no-buffer     Disable buffering of the output stream 
  66. -o/--output <file> Write output to <file> instead of stdout 
  67. -O/--remote-name   Write output to a file named as the remote file 
  68. -p/--proxytunnel   Operate through a HTTP proxy tunnel (using CONNECT) 
  69.     --proxy-basic   Enable Basic authentication on the proxy (H) 
  70.     --proxy-digest  Enable Digest authentication on the proxy (H) 
  71.     --proxy-ntlm    Enable NTLM authentication on the proxy (H) 
  72. -P/--ftp-port <address> Use PORT with address instead of PASV (F) 
  73. -q                 If used as the first parameter disables .curlrc 
  74. -Q/--quote <cmd>   Send command(s) to server before file transfer (F) 
  75. -r/--range <range> Retrieve a byte range from a HTTP/1.1 or FTP server 
  76.     --random-file <file> File for reading random data from (SSL) 
  77. -R/--remote-time   Set the remote file's time on the local output 
  78. -s/--silent        Silent mode. Don't output anything 
  79. -S/--show-error    Show error. With -s, make curl show errors when they occur 
  80.     --socks <host[:port]> Use SOCKS5 proxy on given host + port 
  81.     --stderr <file> Where to redirect stderr. - means stdout 
  82. -t/--telnet-option <OPT=val> Set telnet option 
  83.     --trace <file>  Dump a network/debug trace to the given file 
  84.     --trace-ascii <file> Like --trace but without the hex output 
  85. -T/--upload-file <file> Transfer/upload <file> to remote site 
  86.     --url <URL>     Another way to specify URL to work with 
  87. -u/--user <user[:password]> Specify user and password to use 
  88.                     Overrides -n and --netrc-optional 
  89. -U/--proxy-user <user[:password]> Specify Proxy authentication 
  90. -v/--verbose       Make the operation more talkative 
  91. -V/--version       Show version number and quit 
  92. -w/--write-out [format] What to output after completion 
  93. -x/--proxy <host[:port]> Use HTTP proxy on given port 
  94. -X/--request <command> Specify request command to use 
  95. -y/--speed-time    Time needed to trig speed-limit abort. Defaults to 30 
  96. -Y/--speed-limit   Stop transfer if below speed-limit for 'speed-time' secs 
  97. -z/--time-cond <time> Transfer based on a time condition 
  98. -0/--http1.0       Use HTTP 1.0 (H) 
  99. -1/--tlsv1         Use TLSv1 (SSL) 
  100. -2/--sslv2         Use SSLv2 (SSL) 
  101. -3/--sslv3         Use SSLv3 (SSL) 
  102. -4/--ipv4          Resolve name to IPv4 address 
  103. -6/--ipv6          Resolve name to IPv6 address 
  104. -#/--progress-bar  Display transfer progress as a progress bar 

posted on 2012-11-09 16:39  szgzwf  阅读(295)  评论(0)    收藏  举报