line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Telephone::Lookup::Americom; |
2
|
|
|
|
|
|
|
our $VERSION = 0.01; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
21070
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
658
|
use LWP::Simple; |
|
1
|
|
|
|
|
73570
|
|
|
1
|
|
|
|
|
8
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
1
|
|
|
1
|
0
|
13
|
my $type = shift; |
11
|
1
|
|
33
|
|
|
6
|
my $class = ref($type) || $type; |
12
|
1
|
|
|
|
|
3
|
my $self = {}; |
13
|
1
|
|
|
|
|
3
|
bless $self, $class; |
14
|
1
|
|
|
|
|
5
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub lookup { |
18
|
1
|
|
|
1
|
0
|
8
|
my ($self, $query) = @_; |
19
|
1
|
|
|
|
|
4
|
my $url = "http://decoder.americom.com/decoderscript?Search=$query&handle=101"; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
## Using LWP::Simple to get the html content |
22
|
1
|
|
|
|
|
8
|
my $content = get($url); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
## Format the content, naively, making it easier to parse |
25
|
1
|
|
|
|
|
2405895
|
$content =~ s/[\r\n]+//g; ## get rid of newlines |
26
|
|
|
|
|
|
|
{ |
27
|
1
|
|
|
|
|
4
|
local $/; ## clear default newline separator |
|
1
|
|
|
|
|
6
|
|
28
|
1
|
|
|
|
|
483
|
$content =~ s/<[^>]*>//gs; ## strip html comments. not a very good method, but works for us |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
4
|
my (@results); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
## AREA_CODE Record match |
34
|
1
|
50
|
|
|
|
59
|
if ($content =~ /Found Area Code Match(.?\d+-\d{3}) .{10}(.*?)Created on (.*?\d{4}).*?((Area)|( Country)|( Found))/) { |
35
|
1
|
|
|
|
|
12
|
my $record = { _type => 'AREA_CODE', |
36
|
|
|
|
|
|
|
area_code => $1, |
37
|
|
|
|
|
|
|
location => $2, |
38
|
|
|
|
|
|
|
created_on => $3 |
39
|
|
|
|
|
|
|
}; |
40
|
1
|
|
|
|
|
4
|
push(@results, $record); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
## EXCHANGE_CODE Record match |
44
|
1
|
50
|
|
|
|
15
|
if ($content =~ /Exchange Location:..(.*?)Exchange Type:..(.*?)Owner:..(.*?)Created On:..(.*?\d{4})/) { |
45
|
1
|
|
|
|
|
12
|
my $record = { _type => 'EXCHANGE_CODE', |
46
|
|
|
|
|
|
|
exchange_location => $1, |
47
|
|
|
|
|
|
|
exchange_type => $2, |
48
|
|
|
|
|
|
|
exchange_owner => $3, |
49
|
|
|
|
|
|
|
created_on => $4 |
50
|
|
|
|
|
|
|
}; |
51
|
1
|
|
|
|
|
3
|
push(@results, $record); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
9
|
return @results; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
__END__ |