"Go" method for installing and calling curl under Windows

Source: Internet
Author: User
Tags install openssl

This article transferred from: http://1316478764.iteye.com/blog/2100778

Curl is an open source file Transfer tool that works with URL syntax in the command line mode. It supports many protocols: FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE, and LDAP.
I. Installation of Windows under Curl
1. Get here http://curl.haxx.se/download/ Download the file Curl-7.17.1-win32-ssl.zip, if you do not need to use SSL, you can download the Curl-7.17.1-win32-nossl.zip directly, and can be used directly. In order to facilitate the subsequent request of HTTPS format URLs, we'd better use the SSL feature.

2. Under Windows in order to use the Curl command with SSL, we have to install OpenSSL to http://www.slproweb.com/products/Win32OpenSSL.html here to download Win32openssl_ Light-1_0_1h.exe, can be installed.

3. Next open cmd, switch to the Curl directory, you can use the Curl command directly.

Two. Curl Basic command line
1. View the source code of the webpage, take www.sina.com as an example



To save this file, use the
  Curl-o [file name] www.sina.com
2. Display only header information



Want to display both the header information and source code on the use
Curl-i www.sina.com Results



3. Display the communication process (IP address, port number)



Want to see more details on the use of
Curl--trace output.txt www.sina.com
Information about opening output.txt file

4. Send form Information
Send form information with Get and post two methods. The Get method is relatively simple, as long as the data is attached to the URL behind the line.
Curl Example.com/form.cgi?data=xxx
The Post method must separate the data from the URL, and curl will use the--data parameter.
Curl--data "data=xxx" example.com/form.cgi

5. File Upload
If we had a form like this,
<form method= "POST" enctype= ' Multipart/form-data ' action= "upload.cgi" >
<input Type=file name=upload>
<input type=submit name=press value= "OK" >
</form>
You can use
Curl--form [email protected]--form Press=ok [URL]

6. File download
If you download a picture


Want to follow the name of the server automatically exist locally as long as you change the lowercase o to uppercase O, remove the file name you added to the line
If the download is dropped in the middle, you can also use the command to resume
curl-c-o http://cgi2.tky.3wb.ne.jp/~zzh/screen1.JPG


7.User Agent Field
This field is used to represent the device information for the client. Depending on the field, the server sometimes returns pages of different formats, such as mobile and desktop versions, for different devices.
Curl--user-agent "[user agent]" [URL]

8.cookie
Using the--cookie parameter, you can let curl send a cookie.
Curl--cookie "name=xxx" www.example.com

9. Add header information
Sometimes it is necessary to add a header message to the HTTP request itself. The--header parameter can play this role.
  Curl--header "Content-type:application/json" http://example.com

"Go" method for installing and calling curl under Windows

Related Article

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.