Linux Curl is a tool for uploading or downloading files under the command line via URL syntax, which supports a variety of protocols such as Http,https,ftp,ftps,telnet, which are often used to crawl Web pages and monitor the status of Web servers. One, example of Linux curl usage:1. Linux Curl Crawl Web page: Crawl Baidu: Curl http://www.baidu.comIf found garbled, you can use Iconv transcoding curl http://iframe.ip138.com/ic.asp|iconv-fgb2312use of Iconv see: In Linux/unix system using ICONV command to process text files Chinese garbled problem 2. Linux Curl uses proxy: Linux Curl uses HTTP proxy crawl page: Curl-X 111.95.243.36:80 http://iframe.ip138.com/ic.asp|iconv-fgb2312Curl-x 111.95.243.36:80-u Aiezu:password http://www.baidu.comcrawling pages with socks agent: Curl--SOCKS4 202.113.65.229:443 http://iframe.ip138.com/ic.asp|iconv-fgb2312Curl--SOCKS5 202.113.65.229:443 http://iframe.ip138.com/ic.asp|iconv-fgb2312The proxy server address can be obtained from the crawler agent. 3. Linux Curl Processing cookies receive Cookies:curl-c/tmp/cookies http://www.baidu.com #cookies保存到/tmp/cookies fileSend Cookies:curl-B "KEY1=VAL1;KEY2=VAL2;" http://www.baidu.com #发送cookies文本Curl-b/tmp/cookies http://www.baidu.com #从文件中读取cookies4. Linux Curl Send data: Linux curl Get way submit data: Curl-g-d "Name=value&name2=value2" http://www.baidu.comLinux Curl Post way to submit data: Curl-d "Name=value&name2=value2" http://www.baidu.com #post数据curl-d a=b&c=d&[email protected]/tmp/txt http://www.baidu.com #post文件upload a file as a form: Curl-F [email protected]/tmp/me.txt http://www.aiezu.comcorresponds to the method that sets form form= "POST" and enctype= ' Multipart/form-data 'two properties. 5. Linux Curl HTTP Header processing: Setting HTTP request header information: Curl-a "mozilla/5.0 firefox/21.0" http://www.baidu.com #设置http请求头User-agentCurl-e "http://pachong.org/" http://www.baidu.com #设置http请求头RefererCurl-h "connection:keep-alive \ user-agent:mozilla/5.0" http://www.aiezu.comSet HTTP response header processing: Curl-I. http://www.aiezu.com #仅仅返回headercurl-d/tmp/header http://www.aiezu.com #将http Header saved to/tmp/header file6. Linux Curl Certification: Curl-U aiezu:password http://www.aiezu.com #用户名密码认证CURL-E Mycert.pem https://www.baidu.com #采用证书认证6. Other: Curl-# http://www.baidu.com #以 "#" Output progress barCurl-o/tmp/aiezu http://www.baidu.com #保存http响应到/tmp/aiezuLinux uses Curl Little lessons: HTTP request address URLs to use"" is enclosed. Errors may occur when there are multiple parameters used & connected.
Linux Curl Command Parameters