Curl explains the first---Getting Started and basic use

Source: Internet
Author: User
Tags curl 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 continuation, upload file breakpoint continuation,, HTTP proxy Server pipeline (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. To be exact, curl supports file uploads and downloads, so it's a comprehensive transfer tool, but traditionally, users are accustomed to calling curl a download tool. Curl is developed by the Swedish Curl organization and you can access: Http://curl.haxx. se/gets its source code and related instructions. Given the extensive use of Curl on Linux, IBM contains this software on the CD of the Aix Linux Toolbox, 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 available on the IBM Web site is 7.9.3. The installation under AIX is simple, the IBM website downloads the RPM format package. In Http://curl.haxx. se/docs/, you can download the man Help in UNIX format with detailed instructions for using the Curl tool. Curl is used in the following ways: curl [options] [URL ...] the options are the parameters required for download, about 80, and the various functions of curl are entirely dependent on these parameters. For the use of specific parameters, users can refer to Curl's man help. Below, this article will combine specific examples to illustrate how to use curl to download. edit this paragraph design method Get pageUse the command: Curl Http://curl.haxx. Se This is the simplest way to use it. Use this command to get the 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 are downloading an HTML document, the default will not display the file header, which is the header of the HTML document. To display all, add parameter-I, to display only the head, with the parameter-I. At any time, you can use the-v command to see how curl works, and all of the commands it sends to the server will be displayed. For a breakpoint to continue, you can use the-r parameter to specify the transmission range. Get Form In Web page design, form is a very important element. form is usually used to collect and submit information to the website. There are two ways to submit information, the Get method and the Post method. The Get method is discussed first, such as in the page: <form method= "GET" action= "junk.cgi" > <input type=text name= "Birthyear" > <input Type=submit name=press value= "OK" > </form> a text box and a button labeled "OK" will appear on the browser. By pressing this button, the form submits the text box's data 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 URL of the browser should now be: "Www.hotmail." Com/when/junk.cgi?birthyear=1905&press=ok "For this page, curl can be processed directly, for example to get the page above, just enter: Curl" www.hotmail. Com/when/junk.cgi?birthyear=1905&press=ok "It's OK. The second method that the form uses to submit information is called the Post method, the difference between the post method and the Get method is that when the Get method is used, the target URL is generated in the browser, and post does not. Like get, here's a page: <form method= "POST" action= "junk.cgi" > <input type=text name= "birthyear" > <input type= Submit name=press value= "OK" > </form> a text box and a button labeled "OK" will also appear on the browser. By pressing this button, the table submits data to the server with the Post method alone. 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. By the end of 1995, RFC 1867 defined a new post method for uploading files. Mainly used to upload local files toServer. At this point the page reads: <form method= "POST" enctype= ' Multipart/form-data ' action= "upload.cgi" > <input type=file name= upload> <input type=submit name=press value= "OK" > </form> for this page, Curl uses different: Curl-f upload=@ Localfilename-f Press=ok URL The essence of this command is to upload local files to the server using post. There are many ways to use the post, and users can explore it on their own. using putThe standard way to upload HTTP protocol files is to use put, at which time the Curl command uses the-t parameter: curl-t uploadfile www.uploadhttp. com/receive.cgi About CertificationsCurl can handle authentication pages in a variety of situations, such as a page that downloads a username/password authentication method (usually an input box for entering a user name and password in IE): Curl-u name:password www.secrets. COM if the network goes through an HTTP proxy server, and the proxy server requires a username and password, enter: Curl-u Proxyuser:proxypassword http://curl.haxx. Se any time you need to enter a user name and password, only specify the user name in the parameters and empty the password, curl can interactively let the user enter the password. ReferencesSome network resources must go through another network address when access to the past, which in terms of: referer, reference. For resources of this address, curl can also be downloaded: curl-e http://curl.haxx. Se daniel.haxx. Se Specify user-sideSome network resources first need to determine what browser users are using, to be able to download or browse according to the standard. Curl can now "disguise" itself as any other browser: Curl-a "mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0) "URL This instruction indicates that curl is disguised as a IE5.0, and the user platform is Windows 2000. (The peer 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) "The URL is now curl into Netscape, running on the PIII platform of Linux. COOKIESA cookie is a method that a server often uses to remember customer information. If the cookie is recorded in the file, then 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 website: curl-b cookies.txt-c newcookies.txt www.cookiesite. Com Encrypt HTTPIf the Web page is transmitted via the OpenSSL encrypted HTTPS protocol, curl can be accessed directly: Curl Https://that.secure.server. Com HTTP AuthenticationIf it is an HTTP address with certificate authentication, and the certificate is local, then Curl uses: Curl-e Mycert.pem https://that.secure.server. Com PrecautionsCurl is very broad, users want to use this tool, in addition to the detailed learning parameters, but also need a deep understanding of the various protocols and URLs of HTTP syntax. A few readings are recommended here: the definition of RFC 2616 HTTP protocol syntax. The definition of the RFC 2396 URL syntax. How the RFC 2109 cookie works. RFC 1867 http How to post, and the format of the post. edit this paragraphReprinted from: Http://baike.baidu.com/link?url= ho6jk4oeo66xmpsd5paigdegctyyfrdffnl5zzeascuklj3cnhxouahefe1q5qhso9-s0cd00vjwmmvmroad__
Learning materials: 1 Call Youdao interface translation English: http://hexlee.iteye.com/blog/1442506 2curl using 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.