Proxy List script

This script is a fully automatic proxy list checker in Perl.

It reads from a file called unchecked.txt which contains unverified proxies in <IP>:<port> format, one per line.
Proxies are verified against Google.co.uk, the British Google site. If the test is successful, the proxy is added to checked.txt in the same format.

The script is not multithreaded, so it will be slower than programs like Charon which use multiple threads. On the other hand, it is very easy on the server resources so you may even use it on a shared webserver or small hosting plan. It just required the LWP::UserAgent module which is available on most servers. 5 proxy list sites were built around this script so far.

#!/usr/bin/perl -w

require LWP::UserAgent;
use CGI::Carp qw( fatalsToBrowser );
my $proxystatus=0;
 
print "Content-type:text/html\n\n";

$INFILE = "/var/www/vhosts/myvhost/cgi-bin/unchecked.txt";
open(INFILE) or die("Could not open IN file.");
open(OUTFILE,">/var/www/vhosts/myvhost/cgi-bin/checked.txt") or die ("Could not open OUT file");
print OUTFILE "";
close(OUTFILE);

foreach $proxy (<INFILE>) {
chomp($proxy);
$proxystatus = &testproxy($proxy);
 if ($proxystatus==1)
 {
 open(OUTFILE,">>/var/www/vhosts/myvhost/cgi-bin/checked.txt") or die ("Could not open OUT file");
 print OUTFILE $proxy."\n";
 print "proxy ".$proxy." is ok!\n";
 }
 else
 {
 print "proxy ".$proxy." is bad!\n";
 }
}
close(INFILE);
close(OUTFILE);

sub testproxy
{

my ($proxy) = shift (@_);
 $proxy='http://'.$proxy.'/';
 my $ua = LWP::UserAgent->new;
 $ua->timeout(14);
 $ua->agent('Mozilla/5.0');
 $ua->proxy(['http', 'ftp'], $proxy);
 my $response = $ua->get('http://www.google.co.uk/');
 if ($response->is_success) {
     #print $response->content;  # or whatever
     if ($response->content =~ m/Google/)
     {
     return 1; 
     }
     else
     {
     return 0; 
     }
 }
 else
 {
     return 0;
 }
 
}
 

 

Source: (2006-07-26 23:44:57)