当前位置:网站首页>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
边栏推荐
猜你喜欢

用 PySpark ML 构建机器学习模型

添加路由的2种方式--router

Arduino框架下合宙ESP32C3 +1.8“tft 网络时钟

2022 security officer C certificate test and simulation test in shandong province

什么是遗留代码:有效地处理遗留代码的8个小贴士

How to choose the right oscilloscope probe in different scenarios

【裴蜀定理】CF1055C Lucky Days

LeetCode·301.删除无效的括号·BFS

元宇宙 | 你能通过图灵测试吗?

Shell编程三剑客之awk
随机推荐
什么是遗留代码:有效地处理遗留代码的8个小贴士
软考考生注意!2022年下半年报名详细流程来了!
flinkcdc 读取pgsql 的时间被放大了 有大佬知道咋回事吗 gmt_create':1
mysql cdc (2.1.1)inital snapshot数据库的时候设置了5个并发度,se
leetcode每天5题-Day13
Shield Alt hotkey in vscode
flex related
暑期学前作业
Stacks and Queues | Implementing Queues with Stacks | Implementing Stacks with Queues | Basic Theory and Code Principles
2022G3锅炉水处理考试模拟100题及模拟考试
2022 R2 transportable pressure vessel filling operation examination question bank simulation platform
【LeetCode】Day111-字母异位词分组
FPGA工程师面试试题集锦11~20
【u-boot】u-boot驱动模型分析(02)
awk of the Three Musketeers of Shell Programming
PHPCMS仿站从入门到精通,小白看这一套课程就够了
Thread.sleep, Thread.yield 作用解释
2022年T电梯修理考试题及模拟考试
干货 | 查资料利器:线上图书馆
JavsSE => 多态