4

Curl 发送 URL查询字符串

 1 year ago
source link: https://www.myfreax.com/curl-sends-url-query-string/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Curl 发送 URL查询字符串

Curl 是用于在本地计算机与远程服务器之间传输数据的命令行工具

Updated At 5 Jan 2023 3 min read
By myfreax
Curl 发送 URL查询字符串

Curl 发送 URL查询字符串

Curl 是用于在本地计算机与远程服务器之间传输数据的命令行工具。使用curl时您可以使用HTTP,HTTPS,SCP SFTPFTP等协议下载或上传数据。

Curl 提供了许多选项,使您可以恢复上传/下载,限制带宽,代理支持,用户身份验证等。

在本教程中,我们将说明如何在Linux使用Curl命令下载文件及其选项的详解。如果您未指定使用的协议,Curl默认使用HTTP协议。

Curl 命令已预安装在大多数Linux发行版。要检查你的Linux发行版是否已安装Curl,请按快捷键CTRL+ALT+T打开终端,键入curl,然后按Enter。

安装 Curl

如果已安装curl,则系统将打印curl: try 'curl --help' or 'curl --manual' for more information

否则终端打印消息curl command not found curl命令未找到。如果你尚未安装Curl,则可以使用发行版的软件包管理器安装curl

如果你的计算机运行的是基于Debian的Linux发行版,例如Ubuntu,Linux Mint等。请运行sudo apt install curl命令安装curl。

如果你的计算机运行的是基于Redhat的Linux发行版,例如CentOS,Fedora等。请运行sudo yum install curl命令安装Curl。

sudo yum install curl
sudo apt install curl

发送 URL 查询字符串

发出POST请求的另一种方法是使用Curl 命令的-d选项。在使用-d选项时Curl命令使用application/x-www-form-urlencoded对数据进行编码。

也会指定内容类型为application/x-www-form-urlencoded。使用这种方式发送的请求,就是使用查询字符串发送数据。

如果你需要发送大量的数据你不必多次使用-d选项,可以使用&符号合并数据,比如website=myfreax&[email protected]

curl -X POST -d 'name=myfreax' -d '[email protected]' https://example.com/contact.php

#上面和下面的命令是等价的
curl -X POST -d 'name=myfreax&[email protected]' https://example.com/contact.php
curl-command-examples.webp
Linux Curl命令详解教程

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK