首页 > 系统相关 >Linux - curl 使用方法

Linux - curl 使用方法

时间:2023-02-17 23:33:03浏览次数:49  
标签:username password 方法 github Linux curl txt com

curl 是强大的开源的数据传输工具,它支持很多协议,其中使用最多的是HTTP/HTTPS协议。 curl使用libcurl库,很多编程语音都可以使用这个库

1、curl 基本使用 curl blog.ling218.cn # 输出指定url的html代码 curl github.com # 没有输出,因为github使用了301重定向 curl -L github.com # 输出html代码 curl -v github.com # 获得执行curl时的详细请求/回应信息 curl -o github.html -L github.com # 使用-o选项把返回的html代码保存为文件 curl -o wordpress.zip  https://wordpress.org/latest.zip

2、GET请求 curl https://www.google.com/search?client=safari&q=keyword ? 后跟 field=value&

3、POST请求: curl -d "field1=value1&field2=value2" <url> 上传文件 curl -F "field=@/path/to/file.txt" website.com/uploadfile

4、FTP 使用curl连接ftp服务 curl -u username:password ftp://yourftp.com curl ftp:/username:[email protected] 如果ftp使用了ssl,需要把ftp替换为ftps 上传文件 curl -T file.txt ftps://username:[email protected]/path curl -T {file.txt,file2.txt} ftps://username:[email protected]/path 下载文件 curl ftps://username:[email protected]/path/file.txt -o file.txt

5、其他 curl -x http://127.0.0.1:1717 <url> # 通过代理发送请求 curl -b "mycookie=value" <url> # Cookies curl -u username:password https://yourlogin.com # HTTP认证登录,不是表单形式的认证登录 man curl # 查看man手册

标签:username,password,方法,github,Linux,curl,txt,com
From: https://blog.51cto.com/u_15551039/6064559

相关文章