Парсер прокси на Perl

Root1

Новичок
Статус
offline
Регистрация
23.03.2017
Сообщения
1
Репутация
0
#!/usr/bin/perl -w

use LWP::UserAgent;
use threads;
use threads::shared;
my @sites : shared;
my $threads = 1;
my $proxy = 'proxy.txt';
open (F, ">>$proxy") || die("Could not open ".$proxy." file!!!");
@sites = qw(http://fineproxy.ru/ http://hideme.ru/proxy-list/http/ http://hideme.ru/proxy-list/http-connect/ http://hideme.ru/proxy-list/socks4 http://hideme.ru/proxy-list/socks5/ http://www.proxydb.ru/ http://www.anonproxy.boom.ru/proxy.html http://spys.ru/ http://russianproxy.ru/proxy_list_http_fastest http://spys.ru/proxys/US/ );
my $num;
my $saw;
for(0..$threads) {$trl[$_] = threads->create(\&Grab, $_);}
for(@trl) { $_->join; }
sub Grab
{
while (@sites){
$site = shift @sites;
$ua = new LWP::UserAgent;
$ua->timeout(30);
$data = $ua->get($site)->as_string;
print "Grabbing proxys from: ".$site." ...\n";
while($data =~/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\:(\d{1,4})/msgi) {
print F $1.":".$2."\n";
print $1.":".$2."\n";
}
print "#############################\n";
}
}
close (F);
close (S);