Friday, July 08, 2005

the "unlisted number lister"

#!/usr/bin/perl
use strict;
use warnings;
print <<'tag';
#########################################
# UNL ver. 0.1 #
# Unlisted Number Lister #
# Lists numbers not found in #
# Superpages.com's directory #
# for a given NPA-NXX #
# #
# rEph #
# (robf [at] flamegrilled [dot] net) #
#########################################
tag
# Globals
my %number;
my $BusNum = 0;
my $ResNum = 0;
## Modules
use Time::Duration;
use HTTP::Request::Common;
require LWP::UserAgent;
my $UserAgent = LWP::UserAgent->new;
$UserAgent->agent("Mozilla/5.0");
## Main
my $NPA = checkinput('NPA');
my $NXX = checkinput('NXX');
my $filename = $NPA.".".$NXX.".XXXX.txt";
print "\nOutputting $NPA-$NXX-XXXX's unlisted numbers to $filename\nPlease be patient, this may take a while.\n\n";
print "Scanning Residential Directory\n"."-" x 30 . "\n";
my $start_time = time();
# Residential Search
for (my $suffix = 0; $suffix < 10; $suffix++) {
results($suffix, 1);
}
print "\nScanning Business Directory\n"."-" x 27 . "\n";

# Business Search
for (my $suffix = 0; $suffix < 100; $suffix++) {
results($suffix, 2);
}
print "\nWriting unlisted numbers to file\n" . "-" x 32 . "\n";
sifter();
### Error Checking
sub checkinput {
my $temp = shift;
while (1){
print "Enter the $temp.\n";
chomp($_ = );
if ($_=~/^\d{3,3}?$/) {
return $_;
}
print "$temp must be 3 digits.\n\n";
}
}
## Parsing Results
sub results {
my $CurrentCount = 0;
my $URI;
my $suffix = shift;
my $type = shift;
if ($type == 1) {print "Scanning $NPA-$NXX-$suffix"."xxx";}
elsif ($type == 2) {
$suffix = sprintf("%02d", $suffix);
print "Scanning $NPA-$NXX-$suffix"."xx";}
my $FollowPage = 1;
my $PI = 1;
while ($FollowPage) {
if ($type == 1) {
$URI = "http://directory.superpages.com/wp/results.jsp?SRC=&STYPE=WR&PS=60&PI=$PI&A=$NPA&X=$NXX&P=$suffix***&search=Find";
} elsif ($type == 2) {
$URI = "http://yellowpages.superpages.com/listings.jsp?SRC=&PS=45&A=$NPA&X=$NXX&P=$suffix**&PP=N&STYPE=AP&paging=1&PI=$PI";
}
$FollowPage = 0;
my $response = $UserAgent->request(GET "$URI");
my $content = $response->content;
if ($type == 1) {
if ($FollowPage == 0 && $content=~m/Next Page/) { $FollowPage++; $PI++ }
while ($content=~m/\($NPA\) $NXX - (\d{4,4}?)/go) { unless ($number{$1}) {$ResNum++; $CurrentCount++;} $number{$1} = 1;}
} elsif ($type == 2) {
if ($FollowPage == 0 && $content=~m/>Next/) { $FollowPage++; $PI += 45}
while ($content=~m/\($NPA\) $NXX-(\d{4,4}?)/go) { unless ($number{$1}) {$BusNum++; $CurrentCount++;} $number{$1} = 1; }
}
}
print " - $CurrentCount numbers found\n";
}

### Checks Keys against each possible suffix and outputs nonexisting suffixes
sub sifter {
my $count = 0;
my $sift;
open (OUTPUT, ">>$filename") or die 'Failed to open output file!!\n';
for ($sift = 0; $sift < 10000; $sift++) {
$sift = sprintf("%04d", $sift);
unless ($number{$sift}) {
$count++;
print OUTPUT "$NPA.$NXX.$sift\n";
}
}
close OUTPUT;
print "\nStatistics\n" . "-" x 10 . "\n";
print "$ResNum\tUnique listed Residential numbers found.\n";
print "$BusNum\tUnique listed Business numbers found.\n";
print "$count\tUnlisted numbers found.\n\n";
printf "%.0f%%\tUnlisted\n%.0f%%\tResidential\n%.0f%%\tBusiness\n", $count/10000*100, $ResNum/10000*100, $BusNum/10000*100;
}
print "\nScan was completed in " . duration(time() - $start_time) . ".\n";
exit(0);

OMG LIEK N3W P0ST!!!!!!

heh i just remembered i had this thing this morning :-P
ok .... you know those lame quizes people have in their blogs? well for some reason i've been keeping all teh results from mine in a txt file and for some reason feel like posting them :)

what warcraft race are you?
...
Advanced Global Personality Test Results
Extraversion |||||||||||| 46%
Stability |||||||||||||| 60%
Orderliness |||| 16%
Altruism |||||||||||||||||||| 90%
Interdependence |||||||||||||||||| 76%
Intellectual |||||||||||||||||||| 83%
Mystical |||||||||||||||||||| 83%
Artistic |||||||||||||||||| 76%
Religious |||||||||||||||| 63%
Hedonism |||||| 30%
Materialism |||||| 23%
Narcissism |||||||||| 36%
Adventurousness |||||||||||||||| 70%
Work ethic |||||||||||| 43%
Self absorbed |||| 16%
Conflict seeking |||||||||||||| 56%
Need to dominate |||||| 23%
Romantic |||||||||||||||||| 76%
Avoidant |||||| 23%
Anti-authority |||||||||||| 50%
Wealth |||||||||||||||| 70%
Dependency |||||||||||||||| 63%
Change averse |||||||||||||||||| 76%
Cautiousness |||||||||||||||||| 76%
Individuality |||||||||||||||||| 76%
Sexuality |||||||||||||| 56%
Peter pan complex |||||||||||||| 56%
Physical security |||||||||||||||||||| 90%
Physical Fitness |||||||||||||||||| 77%
Histrionic |||||||||||| 50%
Paranoia |||||||||||||||| 70%
Vanity || 10%
Hypersensitivity |||||||||||||||| 63%
Female cliche |||||||||||| 43%
Take Free Advanced Global Personality Test
personality tests by similarminds.com


You're a Granola Hippie!
You're a Granola Hippie!



YOU ARE... Terrapin Station - A song, divided into
three parts. Full of imagery, it conveys a
message of everyone being in the world, whether
they like it or not. This song comes with a
spirit of adaption, and wonder of the world
around.

"Inspiration, move me brightly/
light the song with sense and color,/
hold away despair/
More than this I will not ask/
faced with mysteries dark and vast/
statements just seem vain at last/
some rise, some fall, some climb/
to get to Terrapin/

Counting stars by candlelight/
all are dim but one is bright:/
the spiral light of Venus/
rising first and shining best,/
From the northwest corner/
of a brand-new crescent moon/
crickets and cicadas sing/
a rare and different tune" - Grateful Dead,
"Terrapin Station" Part II.

"Back in Terrapin, for good or ill
again..." - Part III


What Grateful Dead song are you?
brought to you by Quizilla