Curl usage accumulation

Introduction

curl is a commonly used command line tool to request a web server. Its name means the URL tool of the client.

Its function is very powerful, as many as dozens of command line parameters. If you are proficient, you can completely replace graphical interface tools like Postman.

This article introduces its main command line parameters as a daily reference for easy reference. The content is mainly translated from "curl cookbook" . In order to save space, the following example does not include the runtime output. For beginners, you can read the "curl tutorial for beginners" I wrote before .

Without any parameters, curl will issue a GET request

$ curl https://www.example.com

The above command sends www.example.coma GET request to the server, and the content returned by the server will be output on the command line.

-A: Specify the user agent header of the client, namely User-Agent. The default user agent string for curl is curl/[version]

$ curl -A 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36' https://google.com

The above command will be User-Agentchanged to Chrome browser

 

Guess you like

Origin blog.csdn.net/luolan_hust/article/details/113727170