Skip to content

Latest commit

 

History

History
143 lines (91 loc) · 1.88 KB

curl.md

File metadata and controls

143 lines (91 loc) · 1.88 KB

curl Cheatsheet

Andrew Pennebaker

https://github.com/mcandre/cheatsheets/blob/master/curl.md

About

curl is a command line Web page downloader

Documentation

cURL Documentation

man curl

Install

$ apt-get install curl

$ brew install curl

C:\> chocolatey install curl

Configure

$HOME/.curlrc

Reference Dotfile

Supported protocols

  • HTTP
  • HTTPS
  • FTP
  • SFTP

Basic usage

Output to STDOUT

$ curl <URL> | less

Continue an interrupted download

$ curl -C <URL>

Handle special URL characters

$ curl "<URL>"

Download file

$ curl -O <URL>

Save as

$ curl -o <filename> <URL>

Specify a user agent string

-A Firefox

Show HTTP Headers

-v

Specify HTTP Method

-X POST

Specify Content Type

-H "Content-Type: application/json

Supply JSON Body

-d '{ ... }'

Or

-d @<JSON file>

Crawling Websites

See curlmirror.pl.

Example scripts

Unofficial protocols

HDFS

Instead of hdfs://<host>:8020/<path>, use:

$ curl http://<host>:50075/streamFile/<path>

CouchDB

Instead of couchdb://<authority>, use:

$ curl http://<host>:5984/<authority>

Alternatives

  • wget specializes in webcrawling.
  • lftp specializes in FTP transfers.
  • scp specializes in SSH file transfers.
  • WWW::Mechanize is a Perl library for fine-tuned Web crawling.