All about cURL

0
1556

Download a Single File to stdout

$ curl http://www.centos.org

Save output to file

$ curl -o mygettext.html http://www.gnu.org/software/gettext/manual/gettext.html

Fetch Multiple Files at a time

$ curl -O URL1 -O URL2

$ curl -O http://www.gnu.org/software/gettext/manual/html_node/index.html -O http://www.gnu.org/software/gettext/manual/gettext.html

Lưu ý: Nếu các URL cùng địa chỉ thì cURL sẽ tải trong cùng 1 connection

Follow HTTP Location Headers with -L option

$ curl http://www.google.com
 
<TITLE>302 Moved</TITLE>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.co.in/">here</A>

Continue/Resume a Previous Download

$ curl -O http://www.gnu.org/software/gettext/manual/gettext.html
##############             20.1%

$ curl -C - -O http://www.gnu.org/software/gettext/manual/gettext.html
###############            21.1%

Limit the Rate of Data Transfer

$ curl --limit-rate 1000B -O http://www.gnu.org/software/gettext/manual/gettext.html

Download a file only if it is modified before/after the given time

$ curl -z 21-Dec-11 http://www.example.com/yy.html

Pass HTTP Authentication in cURL

$ curl -u username:password URL

Download Files from FTP server

Download 1 file

$ curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/xss.php

Download a folder

$ curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/

List/Download using Ranges

$ curl   ftp://ftp.uk.debian.org/debian/pool/main/[a-z]/

Upload Files to FTP Server

$ curl -u ftpuser:ftppass -T myfile.txt ftp://ftp.testserver.com
$ curl -u ftpuser:ftppass -T "{file1,file2}" ftp://ftp.testserver.com
$ curl -u ftpuser:ftppass -T - ftp://ftp.testserver.com/myfile_1.txt

More Information using Verbose and Trace Option

$ curl -v http://google.co.in

Get Definition of a Word using DICT Protocol

$ curl dict://dict.org/d:bash
$ curl dict://dict.org/show:db
$ curl dict://dict.org/d:bash:foldoc

Use Proxy to Download a File

$ curl -x proxysever.test.com:3128 http://google.co.in

Send Mail using SMTP Protocol

$ curl --mail-from [email protected] --mail-rcpt [email protected] smtp://mailserver.com
Subject: Testing
This is a test mail
.

Leave a Reply

avatar
  Subscribe  
Notify of