The Curl command is detailed

Source: Internet
Author: User
Tags http authentication http post

One,Curl Command detailed

(1) Curl Command function

The Curl command is a powerful network tool that can download files via HTTP, ftp, upload files, support many protocols such as HTTPS, post, cookies, authentication, download some files from a specified offset, user agent strings, speed limits, File size, progress bar and other features. In fact, curl is far more than the previous features, and you can get more information from the man Curl reading the manual page. Similar tools also have wget. The Curl command uses the Libcurl library to implement, Libcurl library commonly used in the C program to handle HTTP requests, CURLPP is a C + + package Libcurl, these things can be used in crawling Web pages, network monitoring and other aspects of development, The Curl command can help resolve problems that are encountered during development.

(2) Common parameters

The Curl command has a lot of parameters, and here are just a few of the things I've used, especially in shell scripts.

-a/--append attaching to the destination file when uploading a file

-A: Feel free to specify your own browser information as claimed by this visit

-b/--cookie <name=string/file> Cookie string or file read location, use option to append the last cookie information to the HTTP request.

-c/--cookie-jar <file> Write cookies to this file after the operation is complete

-c/--continue-at <offset> Breakpoint Continuation

-d/--data <data> HTTP Post mode transfer data

   --data-ascii <data> post data in ASCII mode
     - -data-binary <data>
     --negotiate Use HTTP authentication
     --digest use digital authentication
     --di Sable-eprt Disable the use of Eprt or lprt
    &NBSP;--DISABLE-EPSV prohibit use of EPSV

-d/--dump-header <file> Write header information to this file

--egd-file <file> set EGD socket path for random data (SSL)

--tcp-nodelay using the tcp_nodelay option

-e/--referer <URL> Specify a reference address

-f/--form <name=content> analog HTTP form submission data

--form-string <name=string> analog HTTP form submission data

-g/--get sending data in a get way

-h/--header

--ignore-content-length the length of the HTTP header information ignored

-i/--include output includes protocol header information

-i/--head only returns header information, using head request

-k/--insecure allow non-use of certificates to SSL sites

-k/--config The specified configuration file read

-l/--list-only lists the file names under the FTP directory

--limit-rate <rate> Set Transfer speed

--local-port<num> forcing the use of local port numbers

-m/--max-time <seconds> Specifies the maximum length of time to process

--max-redirs <num> Set the maximum number of read directories

--max-filesize <bytes> Set the maximum amount of files to download

-o/--output <file> Specify output file name

-o/--remote-name writes the output to the file, preserving the file name of the remote

The-v/--verbose lowercase v parameter, which is especially useful in debugging scripts, is used to print more information, including sent request information.

-s/--slient reduce the output of information, such as progress

--connect-timeout <seconds> Specifies the maximum length of time to attempt a connection

-x/--proxy <proxyhost[:p ort]> Specify proxy server address and port, port defaults to 1080

-u/--user <user[:p assword]> setting up the user and password for the server

-r/--range <range> retrieving byte ranges from http/1.1 or FTP servers

--range-file Read (SSL) random files

-r/--remote-time Preserve remote file time when generating files locally

--retry <num> Specify the number of retries

--retry-delay <seconds> Set retry interval when problems occur with transmission

--retry-max-time <seconds> Set Maximum retry time when there is a problem with the transmission

-s/--silent silent mode. Don't output anything.

-s/--show-error Display Error

--SOCKS4

--SOCKS5

--stderr <file>

-x/--proxy

-x/--request <command> Specify what command. The default HTTP verb for curl is get, which uses the-X parameter to support other verbs.

-t/--upload-file <file> Specify upload file path

(3) Examples of use

1, crawl Cokkie information into a file

Curl-c cookie0.txt-d "username=****&password=***" http://www.kuaipan.cn/accounts/login/

2. Get information by Get method

Curl-g-i-o xsrf.txt-b cookie1.txt-c cookie2.txt http://web.kuaipan.cn/n/drive/home.tmpl/upload

The Curl command is detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.