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.