Curl explains the first---introductory and basic use

Source: Internet
Author: User
Tags curl file upload ftp how to use curl http authentication http post rfc
ConceptIt supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP. Curl also supports HTTPS authentication, HTTP POST method, HTTP put method, FTP upload, Kerberos authentication, HTTP upload, proxy server, cookies, username/password Authentication, download file breakpoint, upload file breakpoint continued transmission, HTTP proxy tunneling, even it supports IPV6, SOCKS5 proxy server, upload files via HTTP proxy server to FTP server and so on, the function is very powerful. Windows operating system under the network ant, the Internet Express (FlashGet) function it can do. Accurately speaking, curl support file upload and download, so is a comprehensive transmission tool, but according to the tradition, the user is used to call curl as the download tool. Curl was developed by the Swedish Curl organization and you can visit: Http://curl.haxx. se/gets its source code and related instructions. Given the extensive use of Curl on Linux, IBM includes this software on the AIX Linux Toolbox CD-ROM, and you can access the IBM Web site: HTTP://WWW-1.IBM. com/servers/aix/products/aixos/linux/altlic.html download it. [1] The latest version of Curl is 7.29.0, the version provided on the IBM Web site is 7.9.3. The installation under Aix is simple, and the IBM website downloads the RPM package. In Http://curl.haxx. se/docs/, you can download the man Help in UNIX format, which has detailed instructions for the use of Curl tools. The usage of curl is: curl [options] [URL ...] where the options are download the required parameters, about 80 or more, the curl function is entirely dependent on these parameters to complete. The use of specific parameters, users can refer to Curl's man help. Below, this article will combine concrete examples to explain how to use curl to download. edit this paragraph design method Get pageUse command: Curl Http://curl.haxx. Se This is the easiest way to use it. This command was used to get http://curl.haxx. Se points to the page, similarly, if the URL here points to a file or a picture can be downloaded directly to the local. If you download an HTML document, the default will not display the file header, the header of the HTML document. To display all, please add the parameter-I, to show only the head, with the parameter-I. At any time, you can use the-v command to see how curl works, and all the commands it sends to the server are displayed. For a continuation of a breakpoint, you can use the-r parameter to specify the transmission range. Get the form In Web page design, form is a very important element. A form is typically used to collect and submit information to a Web site. There are two methods of submitting information, get method and post method. Discuss the Get method first, such as a section on the page: <form method= "got" action= "junk.cgi" > <input type=text name= "Birthyear" > <input Type=submit name=press value= "OK" > </form> then a text box and a button labeled "OK" appear on the browser. By pressing this button, the form submits the data for the text box to the server using the Get method. For example, the original page is in Www.hotmail. com/when/birth.html See, then you enter 1905 in the text box, and then press the OK button, then the browser URL should now be: "Www.hotmail." Com/when/junk.cgi?birthyear=1905&press=ok "For such pages, curl can directly handle, for example, to get the above page, as long as the input: Curl" www.hotmail. Com/when/junk.cgi?birthyear=1905&press=ok "on it. The second way a form is used to submit information is called the Post method, and the difference between the post method and the Get method is that the target URL will be generated in the browser when it is used, and the post will not. Like get, here's a page: <form method= "POST" action= "junk.cgi" > <input type=text name= "birthyear" > <input type= A text box and a button labeled "OK" will also appear on the submit name=press value= "OK" > </form> browser. Press this button to submit the data to the server in the Post method. At this point the URL is not visible, so you need to use a special method to crawl this page: curl-d "Birthyear=1905&press=ok" Www.hotmail. com/when/junk.cgi This command can be done. At the end of 1995, RFC 1867 defined a new post method for uploading files. Mainly used to upload the local files to theServer. This is what the page reads: <form method= "POST" enctype= ' Multipart/form-data ' action= "upload.cgi" > <input type=file upload> <input type=submit name=press value= "OK" > </form> for this page, the Curl usage is different: curl-f upload=@ Localfilename-f Press=ok URL The essence of this command is to upload the local files to the server using post. There are many uses for post, and users can explore for themselves. Use putThe standard method for uploading HTTP protocol files is to use put, when the Curl command uses the-t parameter: curl-t uploadfile www.uploadhttp. com/receive.cgi about CertificationCurl can handle various conditions of the certification page, such as download user name/password Authentication way of the page (in IE is usually a username and password input box): Curl-u name:password www.secrets. COM if the network is through the HTTP proxy server out, and the proxy server requires a username and password, then enter: Curl-u Proxyuser:proxypassword http://curl.haxx. Se any need to enter a username and password, only in the parameters specified username and empty password, curl can interactively let the user enter the password. ReferenceSome network resources access must go through another network address jump past, in terms of the term is: referer, reference. For this kind of address resources, curl can also download: Curl-e Http://curl.haxx. Se daniel.haxx. Se Specify client SideSome network resources first need to determine what the user is using the browser, meet the standard to be able to download or browse. At this point curl can "disguise" themselves into any other browser: curl-a "mozilla/4.0" (compatible; MSIE 5.01; Windows NT 5.0) "URL This instruction indicates curl disguised as IE5.0, the user platform is Windows 2000. (The other server is based on this string to determine the type of client, so even using AIX does not matter). Use: Curl-a "mozilla/4.73 [en] (X11; U Linux 2.2.15 i686) "URL Curl became Netscape at this time, running on Linux on the PIII platform. COOKIESCookies are a common way for a server to memorize customer information. If the cookie is recorded in the file, use the command: Curl-b stored_cookies_in_file www.cookiesite. COM curl can write a new cookie based on the old cookie and send it to the Web site: curl-b cookies.txt-c newcookies.txt www.cookiesite. Com Encrypt HTTPIf a Web page is transmitted through the OpenSSL encrypted HTTPS protocol, curl can directly access: Curl Https://that.secure.server. Com HTTP AuthenticationIf you are using a certificate-authenticated HTTP address, the certificate is local, then Curl uses this: Curl-e Mycert.pem https://that.secure.server. Com Attention MattersCurl is very broad, users want to use this tool, in addition to detailed learning parameters, but also need to understand the various protocols of HTTP and the various syntax of the URL. Several readings are recommended here: RFC 2616 the definition of HTTP protocol syntax. RFC 2396 the definition of URL syntax. RFC 2109 how cookies work. RFC 1867 how HTTP is post and the post format. edit this paragraphReproduced from: http://baike.baidu.com/link?url= ho6jk4oeo66xmpsd5paigdegctyyfrdffnl5zzeascuklj3cnhxouahefe1q5qhso9-s0cd00vjwmmvmroad__
Learning materials: 1 Call Youdao interface translation English: http://hexlee.iteye.com/blog/1442506 2curl Use tutorials   http://www.adeploy.com/2012/07/28/linux-curl-description.html 2  

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.