line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::FoneFinder; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24288
|
use 5.008000; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1006
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
487765
|
|
|
1
|
|
|
|
|
1067
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
WWW::FoneFinder - Provides an interface to FoneFinder.net |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use WWW::FoneFinder; |
18
|
|
|
|
|
|
|
my $ff = WWW::FoneFinder->new; |
19
|
|
|
|
|
|
|
my $phone = $ff->query('4079347639'); # 407-W-DISNEY (Disney Reservations) |
20
|
|
|
|
|
|
|
use Data::Dumper; |
21
|
|
|
|
|
|
|
print Dumper($phone); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Put in a phone number and it will give you the city, state, and telco for that |
26
|
|
|
|
|
|
|
number. The data comes from FoneFinder.net. This only provides data for NANPA |
27
|
|
|
|
|
|
|
phone numbers (US/Canada). |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 new |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Creates WWW::FoneFinder object. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub new |
36
|
|
|
|
|
|
|
{ |
37
|
0
|
|
|
0
|
1
|
|
my $self = bless({}, shift); |
38
|
0
|
|
|
|
|
|
my %args = @_; |
39
|
0
|
|
0
|
|
|
|
$self->{url} = $args{url} || 'http://www.fonefinder.net/findome.php'; |
40
|
0
|
|
0
|
|
|
|
$self->{referer} = $args{referer} || 'http://www.fonefinder.net/index.php'; |
41
|
0
|
|
0
|
|
|
|
$self->{uastring} = $args{uastring} || 'WWW::FoneFinder/'.$VERSION; |
42
|
0
|
|
|
|
|
|
$self->{ua} = $args{ua}; # pass an existing LWP::UserAgent object |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
|
if (!$self->{ua}) |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
|
|
|
$self->{ua} = LWP::UserAgent->new; |
47
|
0
|
|
|
|
|
|
$self->{ua}->agent($self->{uastring}); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 query |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Queries the site. Provide a phone number. It only sends the area code (NPA), |
56
|
|
|
|
|
|
|
prefix (NXX), and first digit of the last four. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Do not include a country code. Do not provide a "1" prefix. Use only the |
59
|
|
|
|
|
|
|
ten-digit phone number. It is okay to include hyphens/dashes/etc; non-digit |
60
|
|
|
|
|
|
|
characters will be removed automatically. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Format must be: NPANXXNNNN (1234567890: 123 = areacode, 456 = prefix, 7890 = |
63
|
|
|
|
|
|
|
last four digits). |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
If you provide "4079347639", it will send 407, 934, and 7. It will not send the |
66
|
|
|
|
|
|
|
last three digits 639 as they are not useful (plus an added privacy bonus). |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub query |
71
|
|
|
|
|
|
|
{ |
72
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my $number = shift; |
74
|
0
|
|
|
|
|
|
$number =~ s/\D+//g; # kill any non-digit chars |
75
|
0
|
|
|
|
|
|
$number =~ s/^(\d{3})//; |
76
|
0
|
|
|
|
|
|
my $npa = $1; |
77
|
0
|
|
|
|
|
|
$number =~ s/^(\d{3})//; |
78
|
0
|
|
|
|
|
|
my $nxx = $1; |
79
|
0
|
|
|
|
|
|
$number =~ s/^(\d)//; |
80
|
0
|
|
|
|
|
|
my $thoublock = $1; |
81
|
0
|
|
|
|
|
|
my $req = HTTP::Request->new(POST => $self->{url}); |
82
|
0
|
0
|
|
|
|
|
$req->referer($self->{referer}) if $self->{referer}; |
83
|
0
|
|
|
|
|
|
$req->content_type('application/x-www-form-urlencoded'); |
84
|
0
|
|
|
|
|
|
$req->content('npa='.$npa.'&nxx='.$nxx.'&thoublock='.$thoublock.'&usaquerytype=1'); |
85
|
0
|
|
|
|
|
|
my $res = $self->{ua}->request($req); |
86
|
0
|
0
|
|
|
|
|
if ($res->is_success) |
87
|
|
|
|
|
|
|
{ |
88
|
0
|
|
|
|
|
|
my $content = $res->content; |
89
|
0
|
|
|
|
|
|
$content =~ s# | ##gi; # in case they decided to be more proper with their HTML it won't break this (hopefully)
90
|
0
|
|
|
|
|
|
$content =~ m##i; |
91
|
0
|
|
|
|
|
|
my $data = $1; |
92
|
0
|
|
|
|
|
|
$data =~ s#?(a|img|br).*?>##gi; |
93
|
0
|
|
|
|
|
|
$data =~ s# |
\s*$##i;
94
|
0
|
|
|
|
|
|
my @data = split(/ |
/i, $data);
95
|
0
|
|
|
|
|
|
shift(@data); # header |
96
|
0
|
|
|
|
|
|
my @list; |
97
|
0
|
|
|
|
|
|
foreach my $row (@data) |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
|
|
|
my @parts = split(/ | /i, $row); |
100
|
0
|
|
|
|
|
|
shift(@parts); # empty |
101
|
0
|
|
|
|
|
|
my $item = { |
102
|
|
|
|
|
|
|
npa => shift(@parts), |
103
|
|
|
|
|
|
|
nxx => shift(@parts), |
104
|
|
|
|
|
|
|
city => shift(@parts), |
105
|
|
|
|
|
|
|
state => shift(@parts), |
106
|
|
|
|
|
|
|
telco => shift(@parts), |
107
|
|
|
|
|
|
|
}; |
108
|
0
|
|
|
|
|
|
push(@list, $item); |
109
|
|
|
|
|
|
|
} |
110
|
0
|
|
|
|
|
|
return \@list; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
else |
113
|
|
|
|
|
|
|
{ |
114
|
0
|
|
|
|
|
|
return undef; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Copyright (C) 2009 Dusty Wilson, Edusty@megagram.comE |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
125
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.10.0 or, |
126
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |