Saturday, January 9, 2016

Checking the proxy servers

Sometimes we need some privacy on the web. So I needed good proxy servers. I googled a bit and found good list of them here:

But checking them one by one is boring, so I copied the interesed one into the file called list (copy/paste interesting fragments from web browser :):|80|flagCanada|80|flagBrazil|18000|flagChina|3128|flagUK|3128|flagCzechia

There are some environment variables called http_proxy and https_proxy. We can set them system-wide to use proxy like this:

export http_proxy="http://host:port"


export http_proxy="http://username:pass@host:port"

if proxy requires autentication.

So to check if proxy works we just need to set this env. variable and try to download something with wget. We can do this in the loop and get this list as input

--- cut ---


for l in $(cat list); do
HOST=$(echo $l | cut -f1 -d '|')
PORT=$(echo $l | cut -f2 -d '|')

export http_proxy="http://${HOST}:${PORT}"
export https_proxy=$http_proxy

wget -T 10 -O ${n}.jpg

unset http_proxy
unset https_proxy


--- cut ---

-T means timeout
-O means name of the output file

This way I got several files numberd as proxy server position on the list. The 0 size ones are non-working proxies.

-rw-r--r--  1 pi pi     0 Jan  9 17:56 10.jpg
-rw-r--r--  1 pi pi 20216 Jun 12  2013 1.jpg
-rw-r--r--  1 pi pi     0 Jan  9 19:23 2.jpg
-rw-r--r--  1 pi pi 20216 Jun 12  2013 3.jpg
-rw-r--r--  1 pi pi     0 Jan  9 19:23 4.jpg
-rw-r--r--  1 pi pi     0 Jan  9 19:23 5.jpg