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:
http://proxylist.hidemyass.com/
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 :):
198.169.246.30|80|flagCanada
200.180.32.58|80|flagBrazil
211.144.81.68|18000|flagChina
84.45.246.38|3128|flagUK
95.168.217.24|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"
or
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 ---
#!/bin/bash
n=1
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 https://www.eff.org/files/https-everywhere2.jpg -T 10 -O ${n}.jpg
unset http_proxy
unset https_proxy
n=n+1
done;
--- 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
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment