Bash

This article provides an example of using a proxy to make an HTTP request with the Bash programming language.

Bash Code

In this example, we use the Residential proxy below:

residential.pingproxies.com:7777:customer-tt_pp_lz_5051-sessid-Z9tCGVYHu:23n22mk22

This proxy is split into four parts separated by colons. We first save the proxy as a string variable, then split it into four parts at each colon (:) and then add it, with authentication, to our proxy dictionary.

#!/usr/bin/env bash
text="residential.pingproxies.com:7777:customer-tt_pp_lz_5051-sessid-Z9tCGVYHu:23n22mk22"
IFS=':'
read -a proxy_parts <<< "$text"
ip_address=${proxy_parts[0]}
port=${proxy_parts[1]}
username=${proxy_parts[2]}
password=${proxy_parts[3]}
curl -x http://$username:$password@$ip_address:$port http://www.google.com/ && echo

Last updated