CURL implements the http get post method, and curl implements getpost

Source: Internet
Author: User

CURL implements the http get post method, and curl implements getpost
Curl is the next powerful http command line tool in Linux and has powerful functions.

I. CURL regular access to HTTP
1. Visit the website
$ Curl http://www.linuxidc.com
After you press enter, the html of www.linuxidc.com is displayed on the screen.


2. Save the page
Use curl option:-o
$ Curl-o page.html http://www.linuxidc.com

You can see a progress indicator of the download page displayed on the screen. After 100%, the download page is saved.

Ii. GET Mode
In GET mode, no option is required. You only need to write the variable in the url,
For example:
$ Curl http://www.linuxidc.com/test.cgi? Param1 = nickwolfe & param2 = 12345

Iii. POST Mode
Use option-d,
For example:
$ Curl-d "param2 = nickwolfe & param2 = 12345" http://www.linuxidc.com/login.cgi


How does the shell script implement a post or get Method for executing http?

Man curl
Check the submitted data section.
 
Curl, socket, file_get_contents, and other methods for obtaining http protocol files. Comparison of advantages and disadvantages and encoding optimization are provided.

Socket is more underlying than TCP;
Curl and file_get_contents are functions on http. The latter (file_get_contents) is very simple to use, but it blocks the current thread without timeout. Therefore, it is not suitable for capturing long-time connections.
File_get_contents cannot POST data. Only GET is allowed.

The best practice is to use curl to encapsulate a "file_get_contents ". Someone has done this by google.

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.