Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #http://cheat.sh/curl
- # Download a single file
- curl http://path.to.the/file
- # Download a file and specify a new filename
- curl http://example.com/file.zip -o new_file.zip
- # Download multiple files
- curl -O URLOfFirstFile -O URLOfSecondFile
- # Download all sequentially numbered files (1-24)
- curl http://example.com/pic[1-24].jpg
- # Download a file and follow redirects
- curl -L http://example.com/file
- # Download a file and pass HTTP Authentication
- curl -u username:password URL
- # Download a file with a Proxy
- curl -x proxysever.server.com:PORT http://addressiwantto.access
- # Download a file from FTP
- curl -u username:password -O ftp://example.com/pub/file.zip
- # Get an FTP directory listing
- curl ftp://username:password@example.com
- # Resume a previously failed download
- curl -C - -o partial_file.zip http://example.com/file.zip
- # Fetch only the HTTP headers from a response
- curl -I http://example.com
- # Fetch your external IP and network info as JSON
- curl http://ifconfig.me/all/json
- # Limit the rate of a download
- curl --limit-rate 1000B -O http://path.to.the/file
- # POST to a form
- curl -F "name=user" -F "password=test" http://example.com
- # POST JSON Data
- curl -H "Content-Type: application/json" -X POST -d '{"user":"bob","pass":"123"}' http://example.com
- # POST data from the standard in / share data on sprunge.us
- curl -F 'sprunge=<-' sprunge.us
- # https://cheatsheet.dennyzhang.com/cheatsheet-curl-a4
- 1.1 Curl Get/Head
- Curl head request =
- curl -I https://www.google.com
- Curl head request with verbose =
- curl -v -I https://www.google.com
- Curl with explicit http method =
- curl -X GET https://www.google.com
- Curl without http proxy =
- curl --noproxy 127.0.0.1 http://www.stackoverflow.com
- Curl has no timeout by default =
- curl --connect-timeout 10 -I -k https://www.google.com
- Curl get with extra headers =
- curl --verbose --header "Host: www.mytest.com:8182" www.google.com
- Curl get response with headers =
- curl -k -v https://www.google.com
- 1.2 Curl POST
- Curl post request =
- curl -d "name=username&password=123456" <URL>
- Curl post send json =
- curl <URL> -H "content-type: application/json" -d "{ \"woof\": \"bark\"}"
- 1.3 Curl Advanced
- Get my public ip =
- curl -L -s http://ipecho.net/plain, curl -L -s http://whatismijnip.nl
- Curl with credential =
- curl -u $username:$password http://repo.dennyzhang.com/README.txt
- Curl upload =
- curl -v -F key1=value1 -F upload=@localfilename <URL>
- Install curl in alpine linux =
- apk add --update curl
- Curl with http2 =
- curl -k -v --http2 https://www.google.com/
- Curl ftp upload =
- curl -T cryptopp552.zip -u test:test ftp://10.32.99.187/
- Curl ftp download =
- curl -u test:test ftp://10.32.99.187/cryptopp552.zip -o cryptopp552.zip
- Curl upload with credential =
- curl -v -u admin:admin123 --upload-file package1.zip http://mysever:8081/dir/package1.zip
- 1.4 Curl Script
- Install packages with curl =
- curl-install-package.sh
- Check a website response time =
- curl-url-time.sh
- Beautify json output for curl response =
- curl-format-json.sh
- Curl run remote scripts =
- curl-remote-scripts.sh
- 1.5 Wget
- Download one url =
- wget -O /tmp/google.html https://google.com
- Download mutiple urls =
- wget https://google.com https://bing.com
- Download a list of urls =
- wget -i url-list.txt, url-list.txt
- #https://gist.github.com/Kartones/5ae36f801f3d51ac1be0
- XML GET
- curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET "http://hostname/resource"
- JSON GET
- curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET "http://hostname/resource"
- JSON PUT
- curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X PUT -d '{"updated_field1":"updated_value1"}' "http://hostname/resourcex"
- JSON POST uploading a file
- curl -i -H 'Accept: application/json' -X POST -F "filename=@/file/path" -F "other_field=its_value" "http://hostname/resource"
- JSON DELETE
- curl -i -H 'Content-Type: application/json' -H 'Accept: application/json' -X DELETE -d '{"key1":"value1"}' "http://hostname/resource"
- "Debugging mode" (without actual content output):
- curl -XGET -vvv http://hostname/resource > dev\null
- Useful arguments
- -k: not check SSL certificates
- -L: follow redirects
- -v: get verbose output
- -V: get headers at output
Add Comment
Please, Sign In to add comment