Linux Curl Command Parameters detailed

Source: Internet
Author: User
Tags curl http request send cookies

Linux Curl is a tool software that uploads or downloads files at the command line via URL syntax, and it supports multiple protocols such as http,https,ftp,ftps,telnet, which are often used to crawl Web pages and monitor Web server status.

1. Linux Curl Crawl Web page:

Crawl Baidu:


If found garbled, you can use Iconv transcoding:

Curl http://if|iconv-fgb2312

Iconv See: Handling text files with the Iconv command under the Linux/unix system in Chinese garbled problem

  2. Linux Curl Use Agent:

Linux Curl uses HTTP proxies to crawl pages:

Curl-x http://if|iconv-fgb2312

Curl-x Aiezu:password

To crawl a page using the socks agent:

Curl--SOCKS4 http://if|iconv-fgb2312

Curl--SOCKS5 http://if|iconv-fgb2312

Proxy server addresses can be retrieved from the crawler agent.

  3. Linux Curl Processing cookies

Receive cookies:

Curl-c/tmp/cookies #cookies保存到/tmp/cookies file

Send cookies:

Curl-b "KEY1=VAL1;KEY2=VAL2;" Http:// #发送cookies文本

Curl-b/tmp/cookies #从文件中读取cookies

 4. Linux Curl Send data:

Linux Curl Get way submit data:

Curl-g-D "Name=value&name2=value2"

Linux Curl Post method submission data:

Curl-d "Name=value&name2=value2" #post数据

curl-d a=b&c=d&txt@/tmp/txt #post文件

To upload a file as a form:

Curl-f File=@/tmp/me.txt

Equivalent to setting the method= "POST" and enctype= ' Multipart/form-data ' two properties for form forms.

  5. Linux Curl HTTP Header processing:

To set HTTP request header information:

Curl-a "mozilla/5.0 firefox/21.0" #设置http请求头User-agent

Curl-e "" #设置http请求头Referer

Curl-h "Connection:keep-alive user-agent:mozilla/5.0"

To set HTTP response header processing:

Curl-i #仅仅返回header

curl-d/tmp/header #将http header saved to/tmp/header file

 6. Linux Curl Certification:

Curl-u Aiezu:password #用户名密码认证

CURL-E Mycert.pem #采用证书认证

 7. Other:

Curl-# #以 "#" Output progress bar

Curl-o/tmp/aiezu #保存http响应到/tmp/aiezu

Linux uses Curl small lessons:

The URL of the HTTP request address is enclosed with "". There may be an error when there are multiple parameters using the & connection.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.