blib/lib/WWW/Search/TheITJobBoard.pm

filter: Statementstmt 25.5% 44 / 172 Branchbran 0.0% 0 / 100 Conditioncond 0.0% 0 / 60 MC/DCmcdc 0.0% 0 / 35 Subroutinesub 81.2% 13 / 16 Podpod 66.6% 2 / 3 totaltotal 15.2% 59 / 386 CC 76 SCAR 76.4
CC
76
Cov
13%
native_retrieve_some
3178.3
native_setup_search
380.0
native_query
6.0
CRAP 2070.4
↑ Summary
1 package WWW::Search::TheITJobBoard;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 our $VERSION = '0.04';
7 1 our $DEBUG = 0;
8 1 our $MAINTAINER = 'Lee Goddard <lgoddard -at- cpan -dot- org';
9  
10 1 our $WIN = ($^O =~ /win\d/ig); # For the Win32 bug
11  
12 1 ▶use base 'WWW::Search';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use WWW::SearchResult;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use HTML::TokeParser;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 =head1 NAME
17  
18 WWW::Search::TheITJobBoard - Search TheITJobBoard.com
19  
20 =cut
21  
22 =head1 SYNOPSIS
23  
24 use WWW::Search::TheITJobBoard;
25 use Data::Dumper;
26 my $oSearch = WWW::Search->new('TheITJobBoard', _debug => undef);
27 $oSearch->native_query(
28 WWW::Search::escape_query("perl"),
29 jobtype => WWW::Search::TheITJobBoard::CONTRACT,
30 );
31 while (my $oResult = $oSearch->next_result){
32 warn Dumper $oResultr;
33 }
34  
35  
36 =head1 DEPENDENCIES
37  
38 L<WWW::Search>, L<HTML::TokeParser>.
39  
40 =head1 DESCRIPTION
41  
42 Gets jobs from the UK IT job site, I<The IT Job Board>.
43  
44 A sub-class of L<WWW::Search> that uses L<HTML::TokeParser> to return C<WWW::SearchResult> objects
45 for each result found when querying C<www.theitjobboard.com>.
46  
47 One frustrating aspect of I<The IT Jobboard> is that, unlike I<JobServe> (L<WWW::Search::Jobserve)>,
48 it doesn't provide an option to list jobs with full descriptions. So this module offers the ability
49 to create such a list: provide the constructor parameter C<detailed>, with a value of C<html> or C<text>
50 to get details as HTML or plain text. This will extend the C<WWW::SearchResult> objects' C<description> field,
51 and also add a C<details> key, which is itself a hash with interesting keys such as C<location> and C<salary>
52 - those keys come directly from the HTML page, so YMMV.
53  
54 At the time of writing, valid options for The IT Job Board search are as below. These should be passed
55 to C<native_query>, as shown in the example.
56  
57 =over 4
58  
59 =item keywords
60  
61 THe keywords your target job description should contain. Default is C<perl>, of course.
62  
63 =item jobtype
64  
65 Valid values are: C<1> for contract (our default), C<2> for permenant, and C<0> for either
66 You may use constants: C<WWW::Search::TheITJobBoard::CONTRACT>, C<WWW::Search::TheITJobBoard::PERM>,
67 C<WWW::Search::TheITJobBoard::ANY>.
68  
69 =cut
70  
71 1 ▶use constant ANY => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
72 1 ▶use constant CONTRACT => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
73 1 ▶use constant PERM => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
74  
75 =item days
76  
77 The age of the posting, in days, according to the site's records. A value of C<0> represents any age.
78 Our default is C<1>.
79  
80 =item orderby
81  
82 Not especially relevant for us: valid values are C<1> to order by relevance to the keywords;
83 C<2> to order by date posted; C<3> orders by salary; C<4> puts non-agency jobs first, which is the default.
84 You may use constants: C<WWW::Search::TheITJobBoard::RELEVANCE>, C<WWW::Search::TheITJobBoard::DATE>,
85 C<WWW::Search::TheITJobBoard::SALARY>, C<WWW::Search::TheITJobBoard::NONAGENCY>
86  
87 =cut
88  
89 1 ▶use constant RELEVANCE => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 1 ▶use constant DATE => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
91 1 ▶use constant SALARY => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
92 1 ▶use constant NONAGENCY => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
93  
94  
95 =item locations[]
96  
97 This ugly-named entity limits the search by location.
98 The default is to return all jobs, regardless. Valid values are:
99 C<undef> to return all jobs;
100 C<180> for UK, C<124> for Netherlands, C<93> for Germany, C<69> for France,
101 C<308> for Switzerland, C<170> for Republic Of Ireland, C<3> for Austria, C<301> for 'the rest Of the world,'
102 C<254> for 'other European.'
103  
104 You may supply C<location> instead of C<location[]>, but you will still have to access the value you set via the latter.
105  
106 =item currpage
107  
108 The number of the page to start at, indexed from C<1>.
109  
110 =item lang
111  
112 Defaults to C<en> for English, but you could try other two-letter ISO codes.
113  
114 =back
115  
116 =cut
117  
118 # "native_setup_search()" is invoked before the search. It is passed a
119 # single argument: the escaped, native version of the query.
120 # http://www.theitjobboard.com/index.php?keywords=HTML&locations%5B%5D=&jobtype=1&days=2&orderby=3&submit=Search&task=JobSearch&xc=0&lang=en
121 # Blx, it takes opts too
122  
123  
124 0 ▶sub native_query {
Subroutine native_query: not called CC=2 SCAR=17.9
Pod documented
125 0 ▶ my ($self, $native_query, $opts) = (shift, shift, ref($_[0])? shift : {@_});
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
126 0 return $self->SUPER::native_query( $native_query, $opts);
127 }
128  
129 # =head2 METHOD native_setup_search
130 #
131 # Sets up default search parameters. B<NOTE> that the first argument is the same as the option C<keywords: see
132 # L<DESCRIPTION>, above. Unlike other modules in this namespace, you may provide options, after the query,
133 # as either a reference to a hash, or as a list.
134 #
135 # =cut
136  
137 0 ▶sub native_setup_search {
Subroutine native_setup_search: not called CC=19 SCAR=59.4
Pod undocumented
138 0 ▶ my ($self, $native_query, $opts) = (shift, shift, ref($_[0])? shift : {@_});
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
139 0 $self->user_agent('non-robot');
140 0 $self->{_hits_per_page} = 100;
141 0 $self->{_next_to_retrieve} = 1;
142 0 ▶ $self->{search_base_url} ||= 'http://www.theitjobboard.com';
Condition0%0/2
$self->{"search_base_url"} ||= "http://www.theitjobboard.com"
l!l
00
MC/DC0%0/1
$self->{"search_base_url"} ||= "http://www.theitjobboard.com"
$self->{"search_base_url"}
Truth table0%0/2
A
A= $self->{"search_base_url"}
Aresult
11
00
143 0 ▶ $self->{search_base_path} ||= '/index.php';
Condition0%0/2
$self->{"search_base_path"} ||= "/index.php"
l!l
00
MC/DC0%0/1
$self->{"search_base_path"} ||= "/index.php"
$self->{"search_base_path"}
Truth table0%0/2
A
A= $self->{"search_base_path"}
Aresult
11
00
144 0 ▶ $self->{search_url} ||= $self->{search_base_url} . $self->{search_base_path};
Condition0%0/3
$self->{"search_url"} ||= $self->{"search_base_url"} . $self->{"search_base_path"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"search_url"} ||= $self->{"search_base_url"} . $self->{"search_base_path"}
$self->{"search_url"} $self->{"search_base_url"} . $self->{"search_base_path"}
Truth table0%0/3
A ||= B
A= $self->{"search_url"}B= $self->{"search_base_url"} . $self->{"search_base_path"}
ABresult
1X1
011
000
145 0 ▶ $self->{_options}->{keywords} ||= $native_query || 'PERL';
Condition0%0/5
$self->{"_options"}{"keywords"} ||= $native_query || "PERL"
l!l&&r!l&&!r
000
$native_query || 'PERL'
l!l
00
MC/DC0%0/2
$self->{"_options"}{"keywords"} ||= $native_query || "PERL"
$self->{"_options"}{"keywords"} $native_query
Truth table0%0/3
A ||= B
A= $self->{"_options"}{"keywords"}B= $native_query
ABresult
1X1
011
000
146 0 ▶ $self->{_options}->{task} ||= 'JobSearch';
Condition0%0/2
$self->{"_options"}{"task"} ||= "JobSearch"
l!l
00
MC/DC0%0/1
$self->{"_options"}{"task"} ||= "JobSearch"
$self->{"_options"}{"task"}
Truth table0%0/2
A
A= $self->{"_options"}{"task"}
Aresult
11
00
147 0 ▶ $self->{_options}->{xc} ||= '0';
Condition0%0/2
$self->{"_options"}{"xc"} ||= 0
l!l
00
MC/DC0%0/1
$self->{"_options"}{"xc"} ||= 0
$self->{"_options"}{"xc"}
Truth table0%0/2
A
A= $self->{"_options"}{"xc"}
Aresult
11
00
148 0 ▶ $self->{_options}->{lang} ||= 'en';
Condition0%0/2
$self->{"_options"}{"lang"} ||= "en"
l!l
00
MC/DC0%0/1
$self->{"_options"}{"lang"} ||= "en"
$self->{"_options"}{"lang"}
Truth table0%0/2
A
A= $self->{"_options"}{"lang"}
Aresult
11
00
149 0 ▶ if ($self->{_options}->{locations}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_options"}{"locations"}) 0 0 0
150 0 $self->{_options}->{'locations[]'} = $self->{_options}->{locations};
151 0 delete $self->{_options}->{locations};
152 }
153 0 ▶ $self->{_options}->{'locations[]'} ||= undef; # 180=UK
Condition0%0/2
$self->{"_options"}{"locations[]"} ||= undef
l!l
00
MC/DC0%0/1
$self->{"_options"}{"locations[]"} ||= undef
$self->{"_options"}{"locations[]"}
Truth table0%0/2
A
A= $self->{"_options"}{"locations[]"}
Aresult
11
00
154 0 ▶ $self->{_options}->{jobtype} ||= '1'; # 0=any, 1=contract, 2=perm
Condition0%0/2
$self->{"_options"}{"jobtype"} ||= 1
l!l
00
MC/DC0%0/1
$self->{"_options"}{"jobtype"} ||= 1
$self->{"_options"}{"jobtype"}
Truth table0%0/2
A
A= $self->{"_options"}{"jobtype"}
Aresult
11
00
155 0 ▶ $self->{_options}->{days} ||= '1'; # 0=all, otherwise literal
Condition0%0/2
$self->{"_options"}{"days"} ||= 1
l!l
00
MC/DC0%0/1
$self->{"_options"}{"days"} ||= 1
$self->{"_options"}{"days"}
Truth table0%0/2
A
A= $self->{"_options"}{"days"}
Aresult
11
00
156 0 ▶ $self->{_options}->{orderby} ||= '4'; # 1=relevance, 2=date posted, 3=salary, 4=non-agency
Condition0%0/2
$self->{"_options"}{"orderby"} ||= 4
l!l
00
MC/DC0%0/1
$self->{"_options"}{"orderby"} ||= 4
$self->{"_options"}{"orderby"}
Truth table0%0/2
A
A= $self->{"_options"}{"orderby"}
Aresult
11
00
157 0 ▶ $self->{_options}->{currpage} ||= 1; # Current page of results
Condition0%0/2
$self->{"_options"}{"currpage"} ||= 1
l!l
00
MC/DC0%0/1
$self->{"_options"}{"currpage"} ||= 1
$self->{"_options"}{"currpage"}
Truth table0%0/2
A
A= $self->{"_options"}{"currpage"}
Aresult
11
00
158 0 ▶ $self->{_debug} ||= $DEBUG;
Condition0%0/3
$self->{"_debug"} ||= $WWW::Search::TheITJobBoard::DEBUG
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"_debug"} ||= $WWW::Search::TheITJobBoard::DEBUG
$self->{"_debug"} $WWW::Search::TheITJobBoard::DEBUG
Truth table0%0/3
A ||= B
A= $self->{"_debug"}B= $WWW::Search::TheITJobBoard::DEBUG
ABresult
1X1
011
000
159 0 ▶ if ($opts){
Branch: 1 branch
BranchTrueFalseTotal
if ($opts) 0 0 0
160 0 foreach my $i (keys %$opts){
161 0 $self->{_options}->{$i} = $opts->{$i};
162 }
163 }
164 0 $self->{_next_url} = $self->{search_url} .'?' . $self->hash_to_cgi_string($self->{_options});
165 }
166  
167  
168  
169  
170 =head2 METHOD native_retrieve_some
171  
172 Retrieve some results. Returns the number of results found. Will make as many HTTP requests
173 as necessary to get to the maximum results you specify.
174  
175 =cut
176  
177 # After WWW::Search::Yahoo::Advanced
178  
179 0 ▶sub native_retrieve_some { my $self = shift;
Subroutine native_retrieve_some: not called CC=57 SCAR=80.6
Pod documented
180 0 $self->{state} = WWW::Search::SEARCH_BEFORE;
181 0 ▶ $self->{number_retrieved} ||= 0;
Condition0%0/2
$self->{"number_retrieved"} ||= 0
l!l
00
MC/DC0%0/1
$self->{"number_retrieved"} ||= 0
$self->{"number_retrieved"}
Truth table0%0/2
A
A= $self->{"number_retrieved"}
Aresult
11
00
182 0 $self->{_done_uris} = {};
183  
184 # printf STDERR (" + %s::native_retrieve_some()\n", __PACKAGE__) if $self->{_debug};
185  
186 # Initially _next_url is preset; we then undef it and try to get it from the HTML returned by the query:
187 HTTP_REQUEST:
188 0 ▶ while (defined $self->{_next_url} and not exists $self->{_done_uris}->{$self->{_next_url}}){ # fast exit if already done
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_next_url"} and not exists $self->{"_done_uris"}{$self->{"_next_url"}}) 0 0 0
Condition0%0/3
defined $self->{"_next_url"} and not exists $self->{"_done_uris"}{$self->{"_next_url"}}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"_next_url"} and not exists $self->{"_done_uris"}{$self->{"_next_url"}}
defined $self->{"_next_url"} not exists $self->{"_done_uris"}{$self->{"_next_url"}}
Truth table0%0/3
A and not(B)
A= defined $self->{"_next_url"}B= not exists $self->{"_done_uris"}{$self->{"_next_url"}}
ABresult
0X0
100
111
189  
190 # If this is not the first page of results, sleep so as to not overload the server:
191 0 ▶ $self->user_agent_delay if 1 < $self->{_next_to_retrieve};
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_next_to_retrieve"} 0 0 0
192  
193 0 $self->{state} = WWW::Search::SEARCH_RETRIEVING;
194  
195 # Get one page of results:
196 0 ▶ print STDERR " + submitting URL (", $self->{_next_url}, ")\n" if $self->{_debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_debug"} 0 0 0
197 0 $self->{response} = $self->http_request($self->http_method, $self->{_next_url});
198 0 ▶ print STDERR " + got response\n", $self->{response}->headers->as_string, "\n" if 2 <= $self->{_debug};
Branch: 1 branch
BranchTrueFalseTotal
if 2 <= $self->{"_debug"} 0 0 0
199 0 $self->{_prev_url} = $self->{_next_url};
200 0 $self->{_done_uris}->{$self->{_next_url}} ++;
201 0 $self->{state} = WWW::Search::SEARCH_UNDERWAY;
202  
203 # Assume there are no more results, unless we find out otherwise when we parse the html:
204 0 $self->{_next_url} = undef;
205 0 ▶ print STDERR " --- HTTP response is:\n", $self->{response}->as_string if 4 < $self->{_debug};
Branch: 1 branch
BranchTrueFalseTotal
if 4 < $self->{"_debug"} 0 0 0
206 0 ▶ if (! $self->{response}->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"response"}->is_success) 0 0 0
207 0 ▶ if ($self->{_debug}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debug"}) 0 0 0
208 0 print STDERR " --- HTTP request failed, response is:\n", $self->{response}->as_string;
209 }
210 0 return undef;
211 }
212  
213 0 my $html = $self->{response}->content;
214  
215 # Parse the output:
216 # No matches:
217 0 ▶ if ($html =~ /There are no vacancies matching your search criteria/g){
Branch: 1 branch
BranchTrueFalseTotal
if ($html =~ /There are no vacancies matching your search criteria/g) 0 0 0
218 0 ▶ if ($self->{_debug}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debug"}) 0 0 0
219 0 print STDERR " --- search failed: there are no vacancies matching your search criteria";
220 }
221 0 return undef;
222 }
223  
224 0 $self->{_parser} = HTML::TokeParser->new(\$html);
225 # Nice ppl they are, they provide a <div id="results"> containing lots of <div class="jobdet">
226 # so loop over div class jobdet:
227 PARSE_PAGE:
228 0 ▶ while (my $token = $self->{_parser}->get_tag("div")) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $token = $self->{"_parser"}->get_tag("div")) 0 0 0
229 # A 'div' with a 'class' attribute:
230 0 ▶ if ($token->[1] and defined $token->[1]->{class}){
Branch: 2 branches
BranchTrueFalseTotal
if ($token->[1] and defined $token->[1]{'class'}) { } 0 0 0
elsif ($token->[1]{'id'} and $token->[1]{'id'} eq 'prevnextpage') { } 0 0 0
Condition0%0/3
$token->[1] and defined $token->[1]{"class"}
!ll&&!rl&&r
000
MC/DC0%0/2
$token->[1] and defined $token->[1]{"class"}
$token->[1] defined $token->[1]{"class"}
Truth table0%0/3
A and B
A= $token->[1]B= defined $token->[1]{"class"}
ABresult
0X0
100
111
231 # Found a job description:
232 0 ▶ use Data::Dumper; die Dumper $token if not $token->[1]->{class};
Subroutine BEGIN: called CC=1 SCAR=1.2
Branch: 1 branch
BranchTrueFalseTotal
unless $token->[1]{"class"} 0 0 0
233 0 ▶ if ($token->[1]->{class} eq 'jobdet'){
Branch: 1 branch
BranchTrueFalseTotal
if ($token->[1]{"class"} eq "jobdet") 0 0 0
234 0 my $xtoken_a = $self->{_parser}->get_tag("a");
235 0 ▶ if (not $xtoken_a){
Branch: 1 branch
BranchTrueFalseTotal
unless ($xtoken_a) 0 0 0
236 0 print STDERR " --- unexpected result format (code 'a'): please inform author";
237 0 return undef;
238 }
239 0 my $title = $self->{_parser}->get_trimmed_text("/a");
240 0 ▶ if (not $title){
Branch: 1 branch
BranchTrueFalseTotal
unless ($title) 0 0 0
241 0 print STDERR " --- unexpected result format (code '/a'): please inform author";
242 0 return undef;
243 }
244 0 my $token_br = $self->{_parser}->get_tag("br");
245 0 ▶ if (not $token_br){
Branch: 1 branch
BranchTrueFalseTotal
unless ($token_br) 0 0 0
246 0 print STDERR " --- unexpected result format (code 'br'): please inform author";
247 0 return undef;
248 }
249 0 my $all = $self->{_parser}->get_trimmed_text("/p");
250 0 ▶ if (not $token_br){
Branch: 1 branch
BranchTrueFalseTotal
unless ($token_br) 0 0 0
251 0 print STDERR " --- unexpected result format (code '/p'): please inform author";
252 0 return undef;
253 }
254 0 my ($last_posted) = $all =~ /LAST POSTED: (\d{2}\/\d{2}\/\d{4} \d{2}:\d{2}:\d{2})/g;
255 0 my $hit = WWW::SearchResult->new;
256 $hit->add_url(
257 ($xtoken_a->[1]->{href} =~ /^\//? $self->{search_base_url} : '')
258 . $xtoken_a->[1]->{href}
259 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$xtoken_a->[1]{'href'} =~ m[^/] ? : 0 0 0
260 0 $hit->title( $title );
261 0 $hit->description( $all );
262 0 $hit->change_date( $last_posted );
263  
264 # Get the details, if user desires:
265 0 ▶ if ($self->{detailed}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"detailed"}) 0 0 0
266 0 ▶ $hit->{details} = {} if not exists $hit->{details};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $hit->{"details"} 0 0 0
267 0 my $response = $self->http_request('GET', $hit->url);
268 0 ▶ print STDERR " + got response for detail\n", $response->headers->as_string, "\n" if 2 <= $self->{_debug};
Branch: 1 branch
BranchTrueFalseTotal
if 2 <= $self->{"_debug"} 0 0 0
269 0 ▶ print STDERR " --- HTTP response for detail is:\n", $response->as_string if 4 < $self->{_debug};
Branch: 1 branch
BranchTrueFalseTotal
if 4 < $self->{"_debug"} 0 0 0
270 0 ▶ if (! $response->is_success) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->is_success) 0 0 0
271 0 ▶ if ($self->{_debug}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_debug"}) 0 0 0
272 0 print STDERR " --- HTTP request for detail failed, response is:\n", $response->as_string;
273 }
274 0 return undef;
275 }
276 0 my $p = HTML::TokeParser->new(\$response->content);
277 # Get to the div id "jobdescription"
278 0 ▶ while (my $xtoken = $p->get_tag("div")){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xtoken = $p->get_tag("div")) 0 0 0
279 0 ▶ last if $xtoken->[1]->{id} and $xtoken->[1]->{id} eq 'jobdescription';
Branch: 1 branch
BranchTrueFalseTotal
if $xtoken->[1]{"id"} and $xtoken->[1]{"id"} eq "jobdescription" 0 0 0
Condition0%0/3
$xtoken->[1]{"id"} and $xtoken->[1]{"id"} eq "jobdescription"
!ll&&!rl&&r
000
MC/DC0%0/2
$xtoken->[1]{"id"} and $xtoken->[1]{"id"} eq "jobdescription"
$xtoken->[1]{"id"} $xtoken->[1]{"id"} eq "jobdescription"
Truth table0%0/3
A and B
A= $xtoken->[1]{"id"}B= $xtoken->[1]{"id"} eq "jobdescription"
ABresult
0X0
100
111
280 }
281 # Just get text?
282 0 ▶ if (lc $self->{detailed} ne 'html'){
Branch: 1 branch
BranchTrueFalseTotal
if (lc $self->{'detailed'} ne 'html') { } 0 0 0
283 0 $hit->{description} = $p->get_trimmed_text('/div')
284 } else {
285 0 $hit->{description} = '';
286 0 ▶ while ($token = $p->get_token){ # reuse $token
Branch: 1 branch
BranchTrueFalseTotal
if ($token = $p->get_token) 0 0 0
287 0 ▶ if ($token->[0] eq 'S'){
Branch: 3 branches
BranchTrueFalseTotal
if ($token->[0] eq 'S') { } 0 0 0
elsif ($token->[0] eq 'S') { } 0 0 0
elsif ($token->[0] eq 'T') { } 0 0 0
288 0 $hit->{description} .= $token->[4];
289 }
290 elsif ($token->[0] eq 'S'){
291 0 $hit->{description} .= $token->[2];
292 }
293 elsif ($token->[0] eq 'T'){
294 0 $hit->{description} .= $token->[2];
295 }
296 }
297 }
298 # Get to the table after the div/id=jobparticulars and div/id=jobs
299 0 ▶ while (my $xtoken = $p->get_tag("div")){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xtoken = $p->get_tag("div")) 0 0 0
300 0 ▶ last if $xtoken->[1]->{id} and $xtoken->[1]->{id} eq 'jobs';
Branch: 1 branch
BranchTrueFalseTotal
if $xtoken->[1]{"id"} and $xtoken->[1]{"id"} eq "jobs" 0 0 0
Condition0%0/3
$xtoken->[1]{"id"} and $xtoken->[1]{"id"} eq "jobs"
!ll&&!rl&&r
000
MC/DC0%0/2
$xtoken->[1]{"id"} and $xtoken->[1]{"id"} eq "jobs"
$xtoken->[1]{"id"} $xtoken->[1]{"id"} eq "jobs"
Truth table0%0/3
A and B
A= $xtoken->[1]{"id"}B= $xtoken->[1]{"id"} eq "jobs"
ABresult
0X0
100
111
301 }
302 0 $p->get_tag("table");
303 # use the table labels as hash keys - naughty...but nice!
304 0 my $key;
305 0 ▶ while (my $xtoken = $p->get_token){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xtoken = $p->get_token) 0 0 0
306 0 ▶ last if $xtoken->[0] eq 'E' and $xtoken->[1] eq 'table';
Branch: 1 branch
BranchTrueFalseTotal
if $xtoken->[0] eq "E" and $xtoken->[1] eq "table" 0 0 0
Condition0%0/3
$xtoken->[0] eq "E" and $xtoken->[1] eq "table"
!ll&&!rl&&r
000
MC/DC0%0/2
$xtoken->[0] eq "E" and $xtoken->[1] eq "table"
$xtoken->[0] eq "E" $xtoken->[1] eq "table"
Truth table0%0/3
A and B
A= $xtoken->[0] eq "E"B= $xtoken->[1] eq "table"
ABresult
0X0
100
111
307 0 ▶ next if $xtoken->[0] ne 'S' or $xtoken->[1] ne'td';
Branch: 1 branch
BranchTrueFalseTotal
if $xtoken->[0] ne "S" or $xtoken->[1] ne "td" 0 0 0
Condition0%0/3
$xtoken->[0] ne "S" or $xtoken->[1] ne "td"
l!l&&r!l&&!r
000
MC/DC0%0/2
$xtoken->[0] ne "S" or $xtoken->[1] ne "td"
$xtoken->[0] ne "S" $xtoken->[1] ne "td"
Truth table0%0/3
A or B
A= $xtoken->[0] ne "S"B= $xtoken->[1] ne "td"
ABresult
1X1
011
000
308 # Set the key
309 0 ▶ if (exists $xtoken->[2]->{class} and $xtoken->[2]->{class} eq 'jobslabel'){
Branch: 2 branches
BranchTrueFalseTotal
if (exists $xtoken->[2]{'class'} and $xtoken->[2]{'class'} eq 'jobslabel') { } 0 0 0
elsif ($key) { } 0 0 0
Condition0%0/3
exists $xtoken->[2]{"class"} and $xtoken->[2]{"class"} eq "jobslabel"
!ll&&!rl&&r
000
MC/DC0%0/2
exists $xtoken->[2]{"class"} and $xtoken->[2]{"class"} eq "jobslabel"
exists $xtoken->[2]{"class"} $xtoken->[2]{"class"} eq "jobslabel"
Truth table0%0/3
A and B
A= exists $xtoken->[2]{"class"}B= $xtoken->[2]{"class"} eq "jobslabel"
ABresult
0X0
100
111
310 0 $key = $p->get_trimmed_text('/td');
311 0 $key =~ s/\s+/_/sg;
312 0 $key =~ s/[^\w\d_]+//sg;
313 0 $key = lc $key;
314 }
315 # Set the value
316 elsif ($key) {
317 0 $hit->{details}->{$key} = $p->get_trimmed_text('/td');
318 0 undef $key;
319 }
320 } # Next token of details' table
321  
322 } # End getting details
323  
324 0 push @{$self->{cache}}, $hit;
325 0 $self->{_num_hits} ++;
326 } # End found job
327  
328 } # End found div/class
329  
330 # Links to more results
331 ▶ elsif ($token->[1]->{id} and $token->[1]->{id} eq 'prevnextpage'){
Condition0%0/3
$token->[1]{"id"} and $token->[1]{"id"} eq "prevnextpage"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->[1]{"id"} and $token->[1]{"id"} eq "prevnextpage"
$token->[1]{"id"} $token->[1]{"id"} eq "prevnextpage"
Truth table0%0/3
A and B
A= $token->[1]{"id"}B= $token->[1]{"id"} eq "prevnextpage"
ABresult
0X0
100
111
332 0 ▶ while (my $xtoken_a = $self->{_parser}->get_tag("a")){
Branch: 1 branch
BranchTrueFalseTotal
if (my $xtoken_a = $self->{"_parser"}->get_tag("a")) 0 0 0
333 0 ▶ next unless $xtoken_a->[1]->{title} and $xtoken_a->[1]->{title} eq 'Next';
Branch: 1 branch
BranchTrueFalseTotal
unless $xtoken_a->[1]{"title"} and $xtoken_a->[1]{"title"} eq "Next" 0 0 0
Condition0%0/3
$xtoken_a->[1]{"title"} and $xtoken_a->[1]{"title"} eq "Next"
!ll&&!rl&&r
000
MC/DC0%0/2
$xtoken_a->[1]{"title"} and $xtoken_a->[1]{"title"} eq "Next"
$xtoken_a->[1]{"title"} $xtoken_a->[1]{"title"} eq "Next"
Truth table0%0/3
A and B
A= $xtoken_a->[1]{"title"}B= $xtoken_a->[1]{"title"} eq "Next"
ABresult
0X0
100
111
334 0 ▶ if ($WIN){
Branch: 1 branch
BranchTrueFalseTotal
if ($WWW::Search::TheITJobBoard::WIN) 0 0 0
335 # Weird bug in the latest (3.19) HTML::Parser.ppm TokeParser binary from AS
336 # So have to do this:
337 0 ($xtoken_a->[1]->{href}) = $xtoken_a->[3] =~ /href=([^\s>]+)/;
338 0 ($xtoken_a->[1]->{href}) = $xtoken_a->[1]->{href} =~ /^.(.*).$/;
339 }
340 0 ▶ my $uri = ($xtoken_a->[1]->{href} =~ /^\//? $self->{search_base_url} : '') . $xtoken_a->[1]->{href};
Branch: 1 branch
BranchTrueFalseTotal
$xtoken_a->[1]{'href'} =~ m[^/] ? : 0 0 0
341 # IF we've not done it:
342 0 ▶ if (not exists $self->{_done_uris}->{$uri}){
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $self->{"_done_uris"}{$uri}) 0 0 0
343 0 $self->{_next_url} = $uri;
344 0 ▶ print STDERR " + next URI: ".$self->{_next_uri} if $self->{_debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_debug"} 0 0 0
345 0 last PARSE_PAGE;
346 }
347 # else { it's the end of the result set }
348 }
349 } # End found more results
350  
351 } # Next PARSE_PAGE
352  
353 0 $self->{_options}->{currpage} ++;
354  
355 0 ▶ last HTTP_REQUEST if $self->{number_retrieved} + $self->{_num_hits} >= $self->{maximum_to_retrieve};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"number_retrieved"} + $self->{"_num_hits"} >= $self->{"maximum_to_retrieve"} 0 0 0
356 } # Next HTTP_REQUEST
357  
358 0 $self->{state} = WWW::Search::SEARCH_DONE;
359 0 return $self->{_num_hits};
360 }
361  
362  
363  
364 1 1;
365  
366 __END__
↑ Summary