当前位置:网站首页>Introduction to curl command
Introduction to curl command
2022-08-10 05:04:00 【Yehenara Hermione】
Introduction to curl command
01
Introduction
curl command is a file transfer tool that works from the command line using URL rules.It supports file uploading and downloading, so it is a comprehensive transfer tool, but according to tradition, curl is used to be called a download tool.As a powerful tool, curl supports many protocols including HTTP, HTTPS, ftp, etc. It also supports POST, cookies, authentication, downloading partial files from a specified offset, user agent string, speed limit, file size, progress bar and other features.To automate web page processing and data retrieval, curl can help.The command is briefly described below.
02
Syntax and parameters
Syntax:
curl(options)(parameters)
Common options:
-a/–append
When uploading a file, append to the target file
-A/–user-agent
Set the user agent to send to the server
-b/–cookie
cookie string or file read location
–basic
Use HTTP Basic Authentication
-c/–cookie-jar
Write the cookie to this file after the operation is complete
-C/–continue-at
Continue from breakpoint
-d/–data
HTTP POST method to transmit data
-D/–dump-header
Write header information to this file
-o/–output
Write output to this file
-O/–remote-name
Write output to this file, preserving the filename of the remote file
-R/–remote-time
Preserve remote file time when generating files locally
-u/–user
Set the server user and password
-U/–proxy-user
Set proxy username and password
03
Example
1. File download and upload
curl can download files through different protocols, and by setting specific command parameters, it can flexibly control the download output.Here are a few simple examples:
- Download a single file
curl http://man.linuxde.net/text.iso
- download multiple files
curl –o http://man.linuxde.net/text1.iso –o http://man.linuxde.net/text.iso
- After downloading the file, output to the specified file,And show progress bar
curl http://man.linuxde.net/text.iso –o filename.iso –press
- control download speed
curl http://man.linuxde.net/text.iso --limit-rate 50k- control download quota
curlhttp://man.linuxde.net/text.iso –max-filesize 1000k
- download from ftp
curl -u ftpuser:ftppass -O ftp://ftp_server/public_html/xss.php- resume the upload
curl http://man.linuxde.net/text.iso -C offset
#Offset is an integer in bytes. If you let curl automatically infer the correct resume position, use -C -: curl -C -http://man.linuxde.net/text.iso- File Upload
curl --form “[email protected]” http://hostname/resource
2. Web page process processing
Curl can transmit data to the server and supports common protocols such as http, https, ftp, etc., so it can also be used to verify the correctness of different requests and the format of the returned data.Here are some common examples:
- View page code
curl www.so.com
- GETRequest
curl 123-_360search POST request
curl -d "userId=28090443&premium=100" "http://www.so.com//addStrategyKeyword
- show headers
curl –i http://www.so.com
- show the communication process
curl –v www.so.com
- Cookie usage
curl –cookie “type=xxx” www.so.com
- add header information
curl --header “xxx:xxx” http://www.so.com
- http authentication curl –user name:password www.so.com
04
Summary
The above are just the common methods of curl command. If there are any deficiencies, you are welcome to correct them. For more detailed usage, you can check this link: http://man.linuxde.net/curl
边栏推荐
猜你喜欢
随机推荐
From entry to mastery of PHPCMS imitation station, Xiaobai is enough to watch this set of courses
一篇文章掌握整个JVM,JVM超详细解析!!!
webrtc学习--websocket服务器(二) (web端播放h264)
Unity implements UI edge detection and drag-and-drop functions
最强大脑(1)
Rpc接口压测
webrtc学习--webrtc桌面采集
深度学习——循环神经网络RNN 未完待续
What is the relationship between legal representative and shareholders?
咨询cdc 2.0 for mysql不执行flush with read lock.怎么保证bin
众昂矿业:萤石下游需求强劲
Big guys, mysql cdc (2.2.1 and previous versions) sometimes has this situation since savepoint, is there anything wrong?
LeetCode 301. Remove Invalid Parentheses BFS
线程(下):读写者模型\环形队列\线程池
aliases节点分析
二进制中负数为何要用补码形式来表示——二进制加减法
Mysql CDC (2.1.1) inital snapshot database set up five concurrent degree, se
基于 EasyCV 复现 DETR 和 DAB-DETR,Object Query 的正确打开方式
2022 security officer C certificate test and simulation test in shandong province
线性模型中的高级特征选择技术——基于R