curl用来请求服务器,表示该命令用来处理客户端的URL
1、使用curl请求https://www.example.com
➜ curl https://www.example.com
<!doctype html>
<html>
<head>
<title>Example Domain</title>
2、参数学习
-
-d:表示post请求
//使用-d参数以后,HTTP 请求会自动加上标头Content-Type : application/x-www-form-urlencoded。并且会自动将请求转为 POST 方法,因此可以省略-X POST。 $ curl -d'login=emma&password=123'-X POST https://google.com/login
-
-F:向服务器上传二进制文件,还可以指定文件名称,文件类型
//向https://google.com/profile网站上传图片 $ curl -F 'file=@photo.png' https://google.com/profile //指定服务器接收文件名称为haha.png,本地图片不是haha.png $ curl -F 'file=@photo.png;filename=haha.png' https://google.com/profile
https://www.ruanyifeng.com/blog/2019/09/curl-reference.html