Thanks, Jesse Taylor
######--START CODE--######
#!/usr/bin/perl -w
#Given a text file containing URLs, this script will extract any IP addresses or email address from said URLs
use LWP::Simple;
print "Enter location of URL list file: "; chomp($infile=<STDIN>); open INFILE, $infile or die "Could not open file $infile";
print "Enter location at which to create output file: "; chomp($outfile=<STDIN>); open OUTFILE, ">$outfile" or die "Could not open/create $outfile";
while($url=<INFILE>) { chomp($url); $html=get("$url") or die "Couldn't open page located at $url";
@ips = $html =~ /(\d{1,3}[0-255]\.\d{1,3}[0-255]\.\d{1,3}[0-255]\.\d{1,3}[0-255])/g; #find and store IP addresses
@emails = $html =~ /([EMAIL PROTECTED])/g; #find email addresses and store
push(@allips, @ips); push(@allemails, @emails);
} ####remove duplicate array members####
for($i=0; $i<(scalar @allips); $i++) { for ($j=0; $j<(scalar @allips); $j++) { if ($allips[$i] eq $allips[$j] && $i!=$j) { splice(@allips, $j, 0); } } }
####remove duplicate array members####
for($i=0; $i<(scalar @allemails); $i++) { for ($j=0; $j<(scalar @allemails); $j++) { if ($allemails[$i] eq $allemails[$j] && $i!=$j) { splice(@allemails, $j, 1); } } }
####Store data in output file####
print OUTFILE "IP Addresses: \n"; foreach (@allips) { print OUTFILE "$_\n"; }
print OUTFILE "\nEmail Addresses: \n";
foreach (@allemails) { print OUTFILE "$_\n"; }
close(INFILE); close(OUTFILE);
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>