fozu
on
Apr 3, 20222022-04-03T00:00:00+08:00
Updated
Jan 30, 20232023-01-30T10:26:58+08:00
1 min read
Curl using Proxy
–preproxy [protocol://]host[:port]
Use the specified SOCKS proxy before connecting to an HTTP or HTTPS -x, –proxy.
1
| curl --preproxy socks5://proxy.example -x http://http.example https://example.com
|
-x, –proxy [protocol://]host[:port]
Use the specified proxy.
1
| curl --proxy http://proxy.example https://example.com
|
Specify Output
-O, –remote-name
Write output to a local file named like the remote file we get.
-o, –output
Write output to instead of stdout. If you are using {} or [] to fetch multiple documents, you should
quote the URL and you can use '#' followed by a number in the specifier. That variable will be replaced
with the current string for the URL being fetched. Like in:
1
2
3
4
5
| curl "http://{one,two}.example.com" -o "file_#1.txt"
# or use several variables like:
curl "http://{site,host}.host[1-5].com" -o "#1_#2"
|
Specify Source Location
-L, –location
1
2
| You can tell curl to not change POST requests to GET after a 30x response by using the dedicated options for
that: --post301, --post302 and --post303
|
1
| curl -L https://example.com
|
Specify Request Method
-X, –request
(HTTP) Specifies a custom request method
to use when communicating with the HTTP server. The specified request
method will be used instead of the method otherwise used (which defaults to GET
)
1
2
3
| curl -H "X-First-Name: Joe" https://example.com
curl -H "User-Agent: yes-please/2000" https://example.com
curl -H "Host:" https://example.com
|