curl brief introduction
curl Is an open source command line tool , It is based on network protocol , Specify URL Network transmission , After getting the data, there is no specific processing ( Such as :html And so on ), Display directly in " standard output "(stdout) On .
curl There are many supported network protocols , Include :DICT、FILE、FTP、FTPS、GOPHER、GOPHERS、HTTP、HTTPS、IMAP、IMAPS、LDAP、LDAPS、MQTT、POP3、POP3S、RTMP、RTMPS、RTSP、SCP、SFTP、SMB、SMBS、SMTP、SMTPS、TELNET and TFTP.
curl There are also many parameters , Here are some common parameters , It is recommended to save .
send out GET request
When curl Without any parameters ,curl Default issue GET request , The content returned by the server will not be parsed and will be displayed directly on the command line . Example :
curl http://www.csdn.net
Because you need to jump to HTTPS, So back 301:
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
send out POST request
Use -d When parameters are ,header Of Content-Type Is automatically assigned to application/x-www-form-urlencoded, And send POST request . Example :
curl -d 'user= Wanmao society &pwd=onemore' http://csdn.net/login
Because you need to jump to HTTPS, Also return to 301:
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
send out json request
send out json The request also requires two parameters :-X Parameter assignment HTTP Requested method ,-H Parameter assignment HTTP Requested header. Example :
curl -X POST -H "Content-Type: application/json; charset=UTF-8" -d '{"user":" Wan Maoxue ","pwd":"onemore"}' http://www.csdn.net/login
among ,-X Parameter assignment HTTP The request method is POST,-H Nibble at specified header Of Content-Type by application/json; charset=UTF-8 ,-d The parameter specifies that the data is {"user":" Wan Maoxue ","pwd":"onemore"} .
Show HTTP Response head
-i The parameter displays the response content of the server at the same time , It also shows HTTP Response head . Example :
curl -i http://www.csdn.net
The response header of the server will be displayed first , Then leave a blank line , Then display the server response content , as follows :
HTTP/1.1 301 Moved Permanently
Server: openresty
Date: Thu, 20 Jan 2022 11:59:42 GMT
Content-Type: text/html
Content-Length: 166
Connection: keep-alive
Keep-Alive: timeout=20
Location: https://www.csdn.net/
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
Show the response process
-v The whole response process of parameter display , We can see what happened at the bottom . Example :
curl -v http://www.csdn.net
It is shown as follows :
* About to connect() to www.csdn.net port 80 (#0)
* Trying 39.106.226.142...
* Connected to www.csdn.net (39.106.226.142) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: www.csdn.net
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: openresty
< Date: Thu, 20 Jan 2022 12:07:40 GMT
< Content-Type: text/html
< Content-Length: 166
< Connection: keep-alive
< Keep-Alive: timeout=20
< Location: https://www.csdn.net/
<
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>openresty</center>
</body>
</html>
among , With * The first line indicates curl Additional information provided , With > The first line represents the request header , < The first line represents the response header .
Only response headers are displayed
Sometimes the response content is too long , When you only care about the response header , have access to -I Parameters . Example :
curl -v http://www.csdn.net
It is shown as follows :
HTTP/1.1 301 Moved Permanently
Server: openresty
Date: Thu, 20 Jan 2022 12:15:30 GMT
Content-Type: text/html
Content-Length: 166
Connection: keep-alive
Keep-Alive: timeout=20
Location: https://www.csdn.net/
Reference link :
https://curl.se/docs/manpage.html
https://www.ruanyifeng.com/blog/2019/09/curl-reference.html
I've seen it here , You and I must be predestined friends , Leave your give the thumbs-up and Focus on , It will become a great thing in the future .
WeChat official account : Wanmao society
Wechat scan QR code
Reply after attention 「 e-book 」
obtain 12 Ben Java Must read technical books

curl More articles about common parameters and examples
- curl Details of common options
curl Details of common options author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . It's time to get off work again , Let's learn about today's Linux Order it ~ I only list out my common parameters , There are others, but we have a few ...
- DB2 Create a database of commonly used parameters
from http://czmmiao.iteye.com/blog/1335801 DB2 Create a database of commonly used parameters This article only introduces DB2 create database Common parameters in Syntax http://publib ...
- chattr The common parameters of
chattr The common parameters of author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . In the actual production environment , Some o & M engineers have to deal with development and testing , The most common deployment interface in our company is . Every day everyone deploys ...
- find Detailed explanation of common parameters
find Detailed explanation of common parameters author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . stay linux In the system , stay init 3 In this case, it's command line mode , At this time, if we want to find a file, we have to rely on a very useful one ...
- cat Detailed explanation of common parameters
cat Detailed explanation of common parameters author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . lately , A friend of mine is right linux Special interest , So I feel like giving him an order every day , It will be used in a month 30 An order , The base ...
- rsync Detailed explanation of common parameters
rsync Detailed explanation of common parameters author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . stay linux in , Everything is a document , Including your terminal , Hardware device information , Catalog , Kernel files and so on . So we will inevitably encounter copying files in our work ...
- Nginx Common parameters of core configuration file
Nginx Common parameters of core configuration file author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . About Nginx Children's shoes can refer to the authoritative documents Nginx Introduction to official documents :http://nginx.org/ ...
- nmap Detailed explanation of common parameters
nmap Detailed explanation of common parameters author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . In the words of Zhao Xin, a hero of the League of Heroes :“ Even if we are outnumbered , The last general can also take the head of the enemy general from all armies !”. Guan Yu of the Three Kingdoms , Yan Liang was beheaded by ten thousand troops , ...
- free Command commonly used parameters
free Command commonly used parameters author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . During the operation and maintenance period, we will often check the server hardware information , Like memory , You may know how to use memory “[[email protected] ...
- tcpdump Detailed explanation of common parameters
tcpdump Detailed explanation of common parameters author : Yin Zhengjie Copyright notice : Original works , Declined reprint ! Otherwise, the legal liability will be investigated . I haven't updated my blog for a long time , It seems that I haven't recovered from the holiday recently , ha-ha ~ Is there a little friend like me ? Return to the right topic , ...
Random recommendation
- mysql Next, convert the delimited string to an array
MySQL Stored procedures can be used to split strings , Here is a detailed introduction to this MySQL Usage of stored procedures , For your reference . There is an existing string , Such as apple,banana,orange,pears,grape, We're going to have to play it ...
- dataTransfer.getData() stay dragover,dragenter,dragleave Unable to get data in
When doing drag and drop related effects , Want to be in ondragover Add some styles to the dragged elements , So in dragover Event through dataTransfer.getData() To get in dragstart Data set in , But it turns out that d ...
- python in del Usage of
python Medium del The usage is quite special , Novice learning often leads to misunderstanding , clarify del Usage of , It can help to understand python Memory problems of . python Of del differ C Of free and C++ Of delete. because pyth ...
- POJ2503Babelfish
http://poj.org/problem?id=2503 This question starts with a dictionary tree , Find it too troublesome ..... #include<cstdio> #include<cstring> ...
- matlab Eigenvalue decomposition and singular value decomposition
Eigenvalue decomposition function eig Format d = eig(A) % O matrix A The eigenvalues of the d, In vector form d. d = eig(A,B) %A.B For the square , Find the generalized eigenvalue d, In vector form d. ...
- UVa 10214 ( Mobius inversion or Euler function ) Trees in a Wood.
The question : This question and POJ 3090 Very similar , seek |x|≤a,|y|≤b The number of integral points that can be seen at the origin K, The number of all integral points is N( Remove the origin ), seek K/N analysis : There are four visible points on the axis , Because the number of points visible in each quadrant is the same ...
- build Intent
Intent be used for activity Between , fragmetn Between , perhaps APP Inter communication , It mainly contains data and Action Two parts : common action It's in string form activity Appoint Intent intent ...
- 【BZOJ2816】【ZJOI2012】 The Internet (Link-Cut Tree)
[BZOJ2816][ZJOI2012] The Internet (Link-Cut Tree) Topic Title Description Algorithm is a typical algorithm to solve the shortest path G, Each point has a weight , Each side has a color . This undirected graph satisfies the following two conditions : For any edge connected by any node , phase ...
- linux Simple kernel list sort
#include <stdio.h> #include <stdlib.h> #define container_of(ptr, type, mem)(type *)((uns ...
- MySQL Some methods of database use
substring_index(windSpeed,)/3.6 as windSpeed Can be .8 km .0m/s To break up Nesting uses replace Method replace( replace( repla ...




![[n32g457] remote monitoring of graffiti cloud based on RT thread and n32g457](/img/c3/5c9970d7e77afce925814d0ecd3b96.jpg)




