In reality, curling with a proxy is way easier than it may seem at the first sight. All it actually takes is a variable in the cURL syntax. You can set up the proxies with several variables using cURL. Let’s dig into some examples:
Use the -x or –proxy command with:
http_proxy [protocol://][:port] – this command will use the HTTP protocol with the proxy.
HTTPS_PROXY [protocol://][:port] – this sets HTTPS as the protocol for the proxy.
You can set proxy protocols through the prefix by using any of the following prefixes listed below:
[url-protocol]_PROXY [protocol://][:port] – this syntax sets the proxy protocol to the one you specify for the URL.
Ever since cURL is syntax-dependent, it offers no user interaction, because of which you have to define a proxy in the cURL syntax. To do it, use the command described below and directly enter proxy credentials, following an example:
Curl -x proxy.proxy-cheap.com:31112 https://ipinfo.io
In this case we use ipinfo.io because it directly returns the proxy information and remains to be extremely helpful whenever you want to ensure the correct proxy usage and setup.
Just in case you want cURL to send an authentication request to Google’s ClientLogin API through a proxy, you would need to change the usual cURL with another proxy parameter such as:
Curl -x proxy.proxy-cheap.com:31112 https://www.google.com/accounts/ClientLogin \
In the example above, cURL will pull data from the API through the proxy server, and the API will only see the proxy IP address. Do not forget that –proxy command can always be used instead of -x.
At Proxy-Cheap you will always find a curl example fully ready in your credentials list. Which will simplify your life, quite a lot.
To check a random rotating proxy on https://ipinfo.io with a cURL, use the following syntax:
curl -v -x http://username:[email protected]:31112 https://ipinfo.io
This command will send a request to ipinfo.io with the HTTP protocol and the proxy.proxy-cheap.com:31112 endpoint (gate).
To check the same proxy with proxy user credentials (login:pass), you must use the -U parameter. Note that the parameter uses the capital U:
Curl -U username:password -x proxy.proxy-cheap.com:31112 https://ipinfo.io
Why should you check proxies with cURL?
Sincerely because it remains to be the easiest way to check your proxies endpoints setup before you start scraping any data. cURL has made it easier for everyone of us and overtime claimed a certain leading place in our industry for over 20 years, setting new standards which have been proven to be stable, effective and extremely efficient.
Proxy-Cheap wishes you a wonderful evening!