line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
90608
|
use 5.12.0; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
133
|
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package WebService::LOC::CongRec::Day; |
4
|
|
|
|
|
|
|
our $VERSION = '0.1_04'; |
5
|
2
|
|
|
2
|
|
613
|
use Moose 1.13; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with 'MooseX::Log::Log4perl'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Data::Dumper; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
An issue of the Congressional Record from a single day on the thomas.loc.gov |
13
|
|
|
|
|
|
|
website. Something along the lines of: |
14
|
|
|
|
|
|
|
http://thomas.loc.gov/cgi-bin/query/B?r111:@FIELD%28FLD003+h%29+@FIELD%28DDATE+20100924%29 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over 1 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item mech |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
A WWW::Mechanize object that we can use to grab the page from Thomas. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'mech' => ( |
29
|
|
|
|
|
|
|
is => 'rw', |
30
|
|
|
|
|
|
|
isa => 'Object', |
31
|
|
|
|
|
|
|
required => 1, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item date |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
The date that this page is from. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has 'date' => ( |
41
|
|
|
|
|
|
|
is => 'ro', |
42
|
|
|
|
|
|
|
isa => 'DateTime', |
43
|
|
|
|
|
|
|
required => 1, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item house |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Which house of Congress this page is from; (s)enate, (h)ouse, (e)xtension of remarks, (d)aily digest |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
has 'house' => ( |
53
|
|
|
|
|
|
|
is => 'ro', |
54
|
|
|
|
|
|
|
isa => 'Str', |
55
|
|
|
|
|
|
|
required => 1, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item pages |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Pages that are part of this day. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has 'pages' => ( |
65
|
|
|
|
|
|
|
is => 'ro', |
66
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
67
|
|
|
|
|
|
|
auto_deref => 1, |
68
|
|
|
|
|
|
|
lazy_build => 1, |
69
|
|
|
|
|
|
|
builder => '_build_pages', |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=back |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 METHODS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head3 _build_pages |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Get an array of the pages from this day. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Note: these URLs are volatile, expiring 30 minutes after creation. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub _build_pages { |
85
|
|
|
|
|
|
|
my ($self) = @_; |
86
|
|
|
|
|
|
|
my @pages; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
$self->mech->get($self->getURL); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# Line looks like: |
91
|
|
|
|
|
|
|
# <B> 7 . </B> [desc] -- <a href="[url]">(Hou...)</a> |
92
|
|
|
|
|
|
|
# URL: /cgi-bin/query/D?r[congress]:[num]:./temp/~r[congress][random]:: |
93
|
|
|
|
|
|
|
my $congress = WebService::LOC::CongRec::Util->getCongressFromYear($self->date->year); |
94
|
|
|
|
|
|
|
my $lineRegex = qr!<B>\ ?\d{1,3}\ \.\ </B> |
95
|
|
|
|
|
|
|
\ .+\ --\ |
96
|
|
|
|
|
|
|
<a\ href=" |
97
|
|
|
|
|
|
|
(/cgi-bin/query/D\?r$congress:\d{1,3}:./temp/~r$congress.+::) |
98
|
|
|
|
|
|
|
">\([HSD] |
99
|
|
|
|
|
|
|
!x; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my @lines = split /\n/, $self->mech->content; |
102
|
|
|
|
|
|
|
foreach my $line (@lines) { |
103
|
|
|
|
|
|
|
if ($line =~ $lineRegex) { |
104
|
|
|
|
|
|
|
push @pages, $1; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
return \@pages; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head3 getURL() |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Get the Thomas URL for this day. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=cut |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub getURL { |
118
|
|
|
|
|
|
|
my ($self) = @_; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# URL looks like |
121
|
|
|
|
|
|
|
# http://thomas.loc.gov/cgi-bin/query/B?r111:@FIELD(FLD003+s)+@FIELD(DDATE+20100924) |
122
|
|
|
|
|
|
|
my $url = 'http://thomas.loc.gov/cgi-bin/query/B?'; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$url .= 'r' . WebService::LOC::CongRec::Util->getCongressFromYear($self->date->year); |
125
|
|
|
|
|
|
|
$url .= ':@FIELD(FLD003+' . $self->house . ')'; |
126
|
|
|
|
|
|
|
$url .= '+@FIELD(DDATE+' . $self->date->strftime('%Y%m%d') . ')'; |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
return $url; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |