Ebay.pm

filter: Statementstmt 16.6% 80 / 481 Branchbran 5.6% 13 / 230 Conditioncond 14.2% 11 / 77 MC/DCmcdc 12.2% 5 / 41 Subroutinesub 47.5% 19 / 40 Podpod 100% 5 / 5 totaltotal 15.2% 133 / 874 CC 154 SCAR 74.4
CC
154
Cov
13%
_parse_tree
4692.0
_parse_enddate
210.0
_parse_bids
132.0
CRAP 1695.2
↑ Summary Ebay/ByEndDate.pm »
1  
2 package WWW::Search::Ebay;
3  
4 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 our $VERSION = 2.282;
8  
9 =head1 NAME
10  
11 WWW::Search::Ebay - backend for searching www.ebay.com
12  
13 =head1 SYNOPSIS
14  
15 use WWW::Search;
16 my $oSearch = new WWW::Search('Ebay');
17 my $sQuery = WWW::Search::escape_query("C-10 carded Yakface");
18 $oSearch->native_query($sQuery);
19 while (my $oResult = $oSearch->next_result())
20 { print $oResult->url, "\n"; }
21  
22 =head1 DESCRIPTION
23  
24 This class is a Ebay specialization of L<WWW::Search>.
25 It handles making and interpreting Ebay searches
26 F<http://www.ebay.com>.
27  
28 This class exports no public interface; all interaction should
29 be done through L<WWW::Search> objects.
30  
31 =head1 NOTES
32  
33 The search is done against CURRENT running AUCTIONS only.
34 (NOT completed auctions, NOT eBay Stores items, NOT Buy-It-Now only items.)
35 (If you want to search completed auctions, use the L<WWW::Search::Ebay::Completed> module.)
36 (If you want to search eBay Stores, use the L<WWW::Search::Ebay::Stores> module.)
37  
38 The query is applied to TITLES only.
39  
40 This module can return only the first 200 results matching your query.
41  
42 In the resulting L<WWW::Search::Result> objects, the description()
43 field consists of a human-readable combination (joined with
44 semicolon-space) of the Item Number; number of bids; and high bid
45 amount (or starting bid amount).
46  
47 In the resulting L<WWW::Search::Result> objects, the end_date() field
48 contains a human-readable DTG of when the auction is scheduled to end
49 (in the form "YYYY-MM-DD HH:MM TZ"). If environment variable TZ is
50 set, the time will be converted to that timezone; otherwise the time
51 will be left in ebay.com's default timezone (US/Pacific).
52  
53 In the resulting L<WWW::Search::Result> objects, the bid_count() field
54 contains the number of bids as an integer.
55  
56 In the resulting L<WWW::Search::Result> objects, the bid_amount()
57 field is a string containing the high bid or starting bid as a
58 human-readable monetary value in seller-native units, e.g. "$14.95" or
59 "GBP 6.00".
60  
61 In the resulting L<WWW::Search::Result> objects, the sold() field will
62 be non-zero if the item has already sold. (Only if you're using
63 WWW::Search::Ebay::Completed)
64  
65 After a successful search, your search object will contain an element
66 named 'categories' which will be a reference to an array of hashes
67 containing names and IDs of categories and nested subcategories, and
68 the count of items matching your query in each category and
69 subcategory. (Special thanks to Nick Lokkju for this code!) For
70 example:
71  
72 $oSearch->{categories} = [
73 {
74 'ID' => '1',
75 'Count' => 19,
76 'Name' => 'Collectibles',
77 'Subcategory' => [
78 {
79 'ID' => '13877',
80 'Count' => 11,
81 'Name' => 'Historical Memorabilia'
82 },
83 {
84 'ID' => '11450',
85 'Count' => 1,
86 'Name' => 'Clothing, Shoes & Accessories'
87 },
88 ]
89 },
90 {
91 'ID' => '281',
92 'Count' => 1,
93 'Name' => 'Jewelry & Watches',
94 }
95 ];
96  
97 If your query string happens to be an eBay item number,
98 (i.e. if ebay.com redirects the query to an auction page),
99 you will get back one WWW::Search::Result without bid or price information.
100  
101 =head1 OPTIONS
102  
103 =over
104  
105 =item Limit search by price range
106  
107 Contributed by Brian Wilson:
108  
109 $oSearch->native_query($sQuery, {
110 _mPrRngCbx=>'1', _udlo=>$minPrice, _udhi=>$maxPrice,
111 } );
112  
113 =back
114  
115 =head1 PUBLIC METHODS OF NOTE
116  
117 =over
118  
119 =cut
120  
121 5 ▶use base 'WWW::Search';
Subroutine BEGIN: called CC=1 SCAR=0.0
122  
123 5 ▶use constant DEBUG_DATES => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
124 5 ▶use constant DEBUG_COLUMNS => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
125  
126 5 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
127 5 ▶use CGI;
Subroutine BEGIN: called CC=1 SCAR=0.0
128 5 ▶use Data::Dumper; # for debugging only
Subroutine BEGIN: called CC=1 SCAR=0.0
129 5 ▶use Date::Manip;
Subroutine BEGIN: called CC=1 SCAR=0.0
130 # Date_Init("setdate=now,America/Los_Angeles");
131 5 ▶use HTML::TreeBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
132 5 ▶use LWP::Simple;
Subroutine BEGIN: called CC=1 SCAR=0.0
133 5 ▶use WWW::Search qw( generic_option strip_tags );
Subroutine BEGIN: called CC=1 SCAR=0.0
134 # We need the version that has the sold() method:
135 5 ▶use WWW::SearchResult 2.072;
Subroutine BEGIN: called CC=1 SCAR=0.0
136 5 ▶use WWW::Search::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
137  
138 5 our $MAINTAINER = 'Martin Thurn <mthurn@cpan.org>';
139 5 my $cgi = new CGI;
140  
141 sub _native_setup_search
142 13 ▶ {
Subroutine _native_setup_search: called CC=14 SCAR=26.4
143 13 my ($self, $native_query, $rhOptsArg) = @_;
144  
145 # Set some private variables:
146 13 ▶ $self->{_debug} ||= $rhOptsArg->{'search_debug'};
Condition100%3/3
$self->{"_debug"} ||= $rhOptsArg->{"search_debug"}
l!l&&r!l&&!r
1111
MC/DC100%2/2
$self->{"_debug"} ||= $rhOptsArg->{"search_debug"}
$self->{"_debug"} $rhOptsArg->{"search_debug"}
Truth table100%3/3
A ||= B
A= $self->{"_debug"}B= $rhOptsArg->{"search_debug"}
ABresult
1X1
011
000
147 13 ▶ $self->{_debug} = 2 if ($rhOptsArg->{'search_parse_debug'});
Branch: 1 branch
BranchTrueFalseTotal
if $rhOptsArg->{"search_parse_debug"} 2 11 13
148 13 ▶ $self->{_debug} ||= 0;
Condition100%2/2
$self->{"_debug"} ||= 0
l!l
211
MC/DC100%1/1
$self->{"_debug"} ||= 0
$self->{"_debug"}
Truth table100%2/2
A
A= $self->{"_debug"}
Aresult
11
00
149  
150 13 my $DEFAULT_HITS_PER_PAGE = 200;
151 13 $self->{'_hits_per_page'} = $DEFAULT_HITS_PER_PAGE;
152  
153 13 $self->user_agent('non-robot');
154 13 $self->agent_name('Mozilla/5.0 (compatible; Mozilla/4.0; MSIE 6.0; Windows NT 5.1; Q312461)');
155  
156 13 $self->{'_next_to_retrieve'} = 0;
157 13 $self->{'_num_hits'} = 0;
158 # As of 2013-03-01 (probably much before that, but first time I
159 # looked at it in quite a while): <p>To use our basic experience
160 # which does not require JavaScript, <a
161 # href="http://www.ebay.com/sch/i.html?LH_Auction=1&_nkw=trinidad+tobago+flag&_armrs=1&_from=&_ipg=50&_jsoff=1">click
162 # here</a>.</p>
163 13 ▶ $self->{search_host} ||= 'http://www.ebay.com'; # as of 2013-03-01
Condition100%2/2
$self->{"search_host"} ||= "http://www.ebay.com"
l!l
76
MC/DC100%1/1
$self->{"search_host"} ||= "http://www.ebay.com"
$self->{"search_host"}
Truth table100%2/2
A
A= $self->{"search_host"}
Aresult
11
00
164 13 ▶ $self->{search_host} ||= 'http://search.ebay.com';
Condition50%1/2
$self->{"search_host"} ||= "http://search.ebay.com"
l!l
130
MC/DC0%0/1
$self->{"search_host"} ||= "http://search.ebay.com"
$self->{"search_host"}
Truth table50%1/2
A
A= $self->{"search_host"}
Aresult
11
00
165 13 ▶ $self->{search_path} ||= '/sch/i.html'; # as of 2013-03-01
Condition100%2/2
$self->{"search_path"} ||= "/sch/i.html"
l!l
76
MC/DC100%1/1
$self->{"search_path"} ||= "/sch/i.html"
$self->{"search_path"}
Truth table100%2/2
A
A= $self->{"search_path"}
Aresult
11
00
166 13 ▶ $self->{search_path} ||= '/ws/search/SaleSearch';
Condition50%1/2
$self->{"search_path"} ||= "/ws/search/SaleSearch"
l!l
130
MC/DC0%0/1
$self->{"search_path"} ||= "/ws/search/SaleSearch"
$self->{"search_path"}
Truth table50%1/2
A
A= $self->{"search_path"}
Aresult
11
00
167 13 ▶ if (!defined($self->{_options}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"_options"}) 11 2 13
168 {
169 # http://shop.ebay.com/items/_W0QQLHQ5fBINZ1?_nkw=trinidad+flag&_sacat=0&_fromfsb=&_trksid=m270.l1313&_odkw=burkina+faso+flag&_osacat=0
170 $self->{_options} = {
171 satitle => $native_query,
172 # Search AUCTIONS ONLY:
173 sasaleclass => 1,
174 # Display item number explicitly:
175 socolumnlayout => 2,
176 # Do not convert everything to US$:
177 socurrencydisplay => 1,
178 sorecordsperpage => $self->{_hits_per_page},
179 _ipg => $self->{_hits_per_page},
180 # Display absolute times, NOT relative times:
181 11 sotimedisplay => 0,
182 # Use the default columns, NOT anything the
183 # user may have customized (which would come
184 # through via cookies):
185 socustoverride => 1,
186 # Output basic HTML, not JavaScript:
187 _armrs => 1,
188 };
189 # https://www.ebay.com/sch/i.html?LH_Auction=1&SortProperty=MetaEndSort&_armrs=1&_ipg=200&_fosrp=1&_nkw=zeppelin&_sop=1
190 $self->{_options} = {
191 _nkw => $native_query,
192 _armrs => 1,
193 # Turn off JavaScript:
194 _jsoff => 1,
195 # Search AUCTIONS ONLY:
196 LH_Auction => 1,
197 _ipg => $self->{_hits_per_page},
198 # Which page are we on:
199 # _from => 2,
200 #
201 11 };
202 } # if
203 13 ▶ if (defined($rhOptsArg))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rhOptsArg) 13 0 13
204 {
205 # Copy in new options.
206 13 foreach my $key (keys %$rhOptsArg)
207 {
208 # print STDERR " DDD inspecting option $key...";
209 20 ▶ if (WWW::Search::generic_option($key))
Branch: 1 branch
BranchTrueFalseTotal
if (WWW::Search::generic_option($key)) { } 15 5 20
210 {
211 # print STDERR "promote & delete\n";
212 15 ▶ $self->{$key} = $rhOptsArg->{$key} if defined($rhOptsArg->{$key});
Branch: 1 branch
BranchTrueFalseTotal
if defined $rhOptsArg->{$key} 14 1 15
213 15 delete $rhOptsArg->{$key};
214 }
215 else
216 {
217 # print STDERR "copy\n";
218 5 ▶ $self->{_options}->{$key} = $rhOptsArg->{$key} if defined($rhOptsArg->{$key});
Branch: 1 branch
BranchTrueFalseTotal
if defined $rhOptsArg->{$key} 4 1 5
219 }
220 } # foreach
221 } # if
222 # Clear the list of results per category:
223 13 $self->{categories} = [];
224 # Finally, figure out the url.
225 13 $self->{_next_url} = $self->{'search_host'} . $self->{'search_path'} .'?'. $self->hash_to_cgi_string($self->{_options});
226 } # _native_setup_search
227  
228  
229 =item user_agent_delay
230  
231 Introduce a few-seconds delay to avoid overwhelming the server.
232  
233 =cut
234  
235 sub user_agent_delay
236 11 ▶ {
Subroutine user_agent_delay: called CC=2 SCAR=6.9
Pod documented
237 11 my $self = shift;
238 # return;
239 11 my $iSecs = int(3 + rand(3));
240 11 ▶ print STDERR " DDD sleeping $iSecs seconds...\n" if (0 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 0 < $self->{"_debug"} 1 10 11
241 11 sleep($iSecs);
242 } # user_agent_delay
243  
244  
245 =item need_to_delay
246  
247 Controls whether we do the delay or not.
248  
249 =cut
250  
251 sub need_to_delay
252 11 ▶ {
Subroutine need_to_delay: called CC=1 SCAR=0.0
Pod documented
253 11 1;
254 } # need_to_delay
255  
256  
257 =item preprocess_results_page
258  
259 Grabs the eBay Official Time so that when we parse the DTG from the
260 HTML, we can convert / return exactly what eBay means for each one.
261  
262 =cut
263  
264 sub preprocess_results_page
265 0 ▶ {
Subroutine preprocess_results_page: not called CC=7 SCAR=40.3
Pod documented
266 0 my $self = shift;
267 0 my $sPage = shift;
268 0 ▶ if (25 < $self->{_debug})
Branch: 1 branch
BranchTrueFalseTotal
if (25 < $self->{"_debug"}) 0 0 0
269 {
270 # print STDERR Dumper($self->{response});
271 # For debugging:
272 0 print STDERR $sPage;
273 0 exit 88;
274 } # if
275 0 ▶ my $sTitle = $self->{response}->header('title') || '';
Condition0%0/2
$self->{'response'}->header('title') || ''
l!l
00
MC/DC0%0/1
$self->{'response'}->header('title') || ''
$self->{'response'}->header('title')
Truth table0%0/2
A
A= $self->{'response'}->header('title')
Aresult
11
00
276 0 my $qrTitle = $self->_title_pattern;
277 0 ▶ if ($sTitle =~ m!$qrTitle!)
Branch: 1 branch
BranchTrueFalseTotal
if ($sTitle =~ /$qrTitle/) { } 0 0 0
278 {
279 # print STDERR " DDD got a Title: ==$sTitle==\n";
280 # This search returned a single auction item page. We do not need
281 # to fetch eBay official time.
282 } # if
283 else
284 {
285 # Use the UserAgent object in $self to fetch the official ebay.com time:
286 0 $self->{_ebay_official_time} = 'now';
287 # my $sPageDate = get('http://cgi1.ebay.com/aw-cgi/eBayISAPI.dll?TimeShow') || '';
288 0 ▶ my $sPageDate = $self->http_request(GET => 'http://viv.ebay.com/ws/eBayISAPI.dll?EbayTime')->content || '';
Condition0%0/2
$self->http_request('GET', 'http://viv.ebay.com/ws/eBayISAPI.dll?EbayTime')->content || ''
l!l
00
MC/DC0%0/1
$self->http_request('GET', 'http://viv.ebay.com/ws/eBayISAPI.dll?EbayTime')->content || ''
$self->http_request('GET', 'http://viv.ebay.com/ws/eBayISAPI.dll?EbayTime')->content
Truth table0%0/2
A
A= $self->http_request('GET', 'http://viv.ebay.com/ws/eBayISAPI.dll?EbayTime')->content
Aresult
11
00
289 0 ▶ if ($sPageDate eq '')
Branch: 1 branch
BranchTrueFalseTotal
if ($sPageDate eq '') { } 0 0 0
290 {
291 0 die " EEE could not fetch official eBay time";
292 }
293 else
294 {
295 0 my $tree = HTML::TreeBuilder->new;
296 0 $tree->utf8_mode('true');
297 0 $tree->parse($sPageDate);
298 0 $tree->eof;
299 0 my $s = $tree->as_text;
300 # print STDERR " DDD official time =====$s=====\n";
301 0 ▶ if ($s =~ m!The official eBay Time is now:(.+?(P[SD]T))\s*Pacific\s!i)
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /The official eBay Time is now:(.+?(P[SD]T))\s*Pacific\s/i) 0 0 0
302 {
303 0 my ($sDateRaw, $sTZ) = ($1, $2);
304 0 DEBUG_DATES && print STDERR " DDD official time raw ==$sDateRaw==\n";
305 # Apparently, ParseDate() automatically converts to local timezone:
306 0 my $date = ParseDate($sDateRaw);
307 0 DEBUG_DATES && print STDERR " DDD official time cooked ==$date==\n";
308 0 $self->{_ebay_official_time} = $date;
309 } # if
310 } # else
311 } # else
312 0 return $sPage;
313 # Ebay used to send malformed HTML:
314 # my $iSubs = 0 + ($sPage =~ s!</FONT></TD></FONT></TD>!</FONT></TD>!gi);
315 # print STDERR " DDD deleted $iSubs extraneous tags\n" if 1 < $self->{_debug};
316 } # preprocess_results_page
317  
318 sub _cleanup_url
319 0 ▶ {
Subroutine _cleanup_url: not called CC=2 SCAR=17.9
320 0 my $self = shift;
321 0 ▶ my $sURL = shift() || '';
Condition0%0/2
shift() || ''
l!l
00
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
322 # Make sure we don't return two different URLs for the same item:
323 0 $sURL =~ s!&rd=\d+!!;
324 0 $sURL =~ s!&category=\d+!!;
325 0 $sURL =~ s!&ssPageName=[A-Z0-9]+!!;
326 0 return $sURL;
327 } # _cleanup_url
328  
329 sub _format_date
330 0 ▶ {
Subroutine _format_date: not called CC=1 SCAR=6.9
331 0 my $self = shift;
332 0 return UnixDate(shift, '%Y-%m-%d %H:%M %Z');
333 } # _format_date
334  
335 sub _bidcount_as_text
336 0 ▶ {
Subroutine _bidcount_as_text: not called CC=3 SCAR=24.8
337 0 my $self = shift;
338 0 my $hit = shift;
339 0 ▶ my $iBids = $hit->bid_count || 'no';
Condition0%0/2
$hit->bid_count || 'no'
l!l
00
MC/DC0%0/1
$hit->bid_count || 'no'
$hit->bid_count
Truth table0%0/2
A
A= $hit->bid_count
Aresult
11
00
340 0 my $s = "$iBids bid";
341 0 ▶ $s .= 's' if ($iBids ne '1');
Branch: 1 branch
BranchTrueFalseTotal
if $iBids ne 1 0 0 0
342 0 $s .= '; ';
343 } # _bidcount_as_text
344  
345 sub _bidamount_as_text
346 0 ▶ {
Subroutine _bidamount_as_text: not called CC=3 SCAR=24.8
347 0 my $self = shift;
348 0 my $hit = shift;
349 0 ▶ my $iPrice = $hit->bid_amount || 'unknown';
Condition0%0/2
$hit->bid_amount || 'unknown'
l!l
00
MC/DC0%0/1
$hit->bid_amount || 'unknown'
$hit->bid_amount
Truth table0%0/2
A
A= $hit->bid_amount
Aresult
11
00
350 0 my $sDesc = '';
351 0 ▶ $sDesc .= $hit->bid_count ? 'current' : 'starting';
Branch: 1 branch
BranchTrueFalseTotal
$hit->bid_count ? : 0 0 0
352 0 $sDesc .= " bid $iPrice";
353 } # _bidamount_as_text
354  
355 sub _create_description
356 0 ▶ {
Subroutine _create_description: not called CC=3 SCAR=24.8
357 0 my $self = shift;
358 0 my $hit = shift;
359 0 ▶ my $iItem = $hit->item_number || 'unknown';
Condition0%0/2
$hit->item_number || 'unknown'
l!l
00
MC/DC0%0/1
$hit->item_number || 'unknown'
$hit->item_number
Truth table0%0/2
A
A= $hit->item_number
Aresult
11
00
360 0 ▶ my $sWhen = shift() || 'current';
Condition0%0/2
shift() || 'current'
l!l
00
MC/DC0%0/1
shift() || 'current'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
361 # print STDERR " DDD _c_d($iItem, $iBids, $iPrice, $sWhen)\n";
362 0 my $sDesc = "Item \043$iItem; ". $self->_bidcount_as_text($hit);
363 0 $sDesc .= $self->_bidamount_as_text($hit);
364 0 return $sDesc;
365 } # _create_description
366  
367 sub _parse_category
368 0 ▶ {
Subroutine _parse_category: not called CC=6 SCAR=37.4
369 0 my $self = shift;
370 0 my $oTD = shift;
371 0 ▶ return -1 if ! ref $oTD;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oTD 0 0 0
372 0 my $oA = $oTD->look_down(_tag => 'a');
373 0 ▶ return -1 if ! ref $oA;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oA 0 0 0
374 0 ▶ if (DEBUG_COLUMNS || (1 < $self->{_debug}))
Branch: 1 branch
BranchTrueFalseTotal
if (1 < $self->{"_debug"}) 0 0 0
375 {
376 0 my $s = $oA->as_HTML;
377 0 print STDERR " DDD TDcategory's A ===$s===\n";
378 } # if
379 0 ▶ my $sURL = $oA->attr('href') || q{};
Condition0%0/2
$oA->attr('href') || ''
l!l
00
MC/DC0%0/1
$oA->attr('href') || ''
$oA->attr('href')
Truth table0%0/2
A
A= $oA->attr('href')
Aresult
11
00
380 0 ▶ if ($sURL =~ m/sibeleafcat=(\d+)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($sURL =~ /sibeleafcat=(\d+)/) 0 0 0
381 {
382 0 return $1;
383 } # if
384 0 return -1;
385 } # _parse_category
386  
387 sub _parse_price
388 0 ▶ {
Subroutine _parse_price: not called CC=10 SCAR=47.0
389 0 my $self = shift;
390 0 my $oTDprice = shift;
391 0 my $hit = shift;
392 0 ▶ return 0 unless (ref $oTDprice);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oTDprice 0 0 0
393 0 my $s = $oTDprice->as_HTML;
394 0 ▶ if (DEBUG_COLUMNS || (1 < $self->{_debug}))
Branch: 1 branch
BranchTrueFalseTotal
if (1 < $self->{"_debug"}) 0 0 0
395 {
396 0 print STDERR " DDD try TDprice ===$s===\n";
397 } # if
398 0 ▶ if ($oTDprice->attr('class') =~ m'\bebcBid\b')
Branch: 1 branch
BranchTrueFalseTotal
if ($oTDprice->attr("class") =~ /\bebcBid\b/) 0 0 0
399 {
400 # If we see this, we must have been searching for Stores items
401 # but we ran off the bottom of the Stores item list and ran
402 # into the list of "other" items.
403 0 return 1;
404 # We could probably return 0 to abandon the rest of the page, but
405 # maybe just maybe we hit this because of a parsing glitch which
406 # might correct itself on the next TD.
407 } # if
408 0 ▶ if ($oTDprice->attr('class') !~ m'\b(ebcPr|prices|prc)\b')
Branch: 1 branch
BranchTrueFalseTotal
unless ($oTDprice->attr("class") =~ /\b(ebcPr|prices|prc)\b/) 0 0 0
409 {
410 # If we see this, we probably were searching for Store items
411 # but we ran off the bottom of the Store item list and ran
412 # into the list of Auction items.
413 0 return 0;
414 # There is a separate backend for searching Auction items!
415 } # if
416 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($oTDprice->look_down("_tag", "span", "class", "ebSold") or $oTDprice->look_down("_tag", "span", "class", "bold bidsold")) 0 0 0
Condition0%0/3
$oTDprice->look_down("_tag", "span", "class", "ebSold") or $oTDprice->look_down("_tag", "span", "class", "bold bidsold")
l!l&&r!l&&!r
000
MC/DC0%0/2
$oTDprice->look_down("_tag", "span", "class", "ebSold") or $oTDprice->look_down("_tag", "span", "class", "bold bidsold")
$oTDprice->look_down("_tag", "span", "class", "ebSold") $oTDprice->look_down("_tag", "span", "class", "bold bidsold")
Truth table0%0/3
A or B
A= $oTDprice->look_down("_tag", "span", "class", "ebSold")B= $oTDprice->look_down("_tag", "span", "class", "bold bidsold")
ABresult
1X1
011
000
417 $oTDprice->look_down(_tag => 'span',
418 class => 'ebSold')
419 ||
420 $oTDprice->look_down(_tag => 'span',
421 class => 'bold bidsold')
422 )
423 {
424 # This item sold, even if it had no bids (i.e. Buy-It-Now)
425 0 $hit->sold(1);
426 } # if
427 0 ▶ if (my $oChild = $oTDprice->look_down(_tag => 'div',
Branch: 1 branch
BranchTrueFalseTotal
if (my $oChild = $oTDprice->look_down("_tag", "div", "itemprop", "price")) 0 0 0
428 itemprop => 'price'))
429 {
430 # As of 2013-03, we need to separate out the price and the bid:
431 0 $oTDprice = $oChild;
432 } # if
433 0 my $iPrice = $oTDprice->as_text;
434 0 ▶ print STDERR " DDD raw iPrice ===$iPrice===\n" if (DEBUG_COLUMNS || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
435 0 $iPrice =~ s!&pound;!GBP!;
436 0 $iPrice =~ s!\s*Trending.+!!;
437 0 $iPrice =~ s!\s*Was.+!!;
438 # Convert nbsp to regular space:
439 0 $iPrice =~ s!\240!\040!g;
440 # I don't know why there are sometimes weird characters in there:
441 0 $iPrice =~ s!&Acirc;!!g;
442 0 $iPrice =~ s!Â!!g;
443 0 my $currency = $self->_currency_pattern;
444 0 my $W = $self->whitespace_pattern;
445 0 $iPrice =~ s!($currency)$W*($currency)!$1 (Buy-It-Now for $2)!;
446 0 ▶ if ($iPrice =~ s/FREE\s+SHIPPING//i)
Branch: 1 branch
BranchTrueFalseTotal
if ($iPrice =~ s/FREE\s+SHIPPING//i) 0 0 0
447 {
448 0 $hit->shipping('free');
449 } # if
450 0 $hit->bid_amount($iPrice);
451 0 return 1;
452 } # _parse_price
453  
454 sub _parse_bids
455 0 ▶ {
Subroutine _parse_bids: not called CC=11 SCAR=48.8
456 0 my $self = shift;
457 0 my $oTDbids = shift;
458 0 my $hit = shift;
459 0 my $iBids = 0;
460 0 ▶ if (ref $oTDbids)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oTDbids) 0 0 0
461 {
462 0 ▶ if (my $oChild = $oTDbids->look_down(_tag => 'div',
Branch: 1 branch
BranchTrueFalseTotal
if (my $oChild = $oTDbids->look_down("_tag", "div", "class", "bids")) 0 0 0
463 class => 'bids'))
464 {
465 # As of 2013-03, we need to separate out the price and the bid:
466 0 $oTDbids = $oChild;
467 } # if
468 0 my $s = $oTDbids->as_HTML;
469 0 ▶ if (DEBUG_COLUMNS || (1 < $self->{_debug}))
Branch: 1 branch
BranchTrueFalseTotal
if (1 < $self->{"_debug"}) 0 0 0
470 {
471 0 print STDERR " DDD TDbids ===$s===\n";
472 } # if
473 0 ▶ if ($oTDbids->attr('class') !~ m'\b(ebcBid|bids)\b')
Branch: 1 branch
BranchTrueFalseTotal
unless ($oTDbids->attr("class") =~ /\b(ebcBid|bids)\b/) 0 0 0
474 {
475 # If we see this, we probably were searching for Store items
476 # but we ran off the bottom of the Store item list and ran
477 # into the list of Auction items.
478 0 return 0;
479 # There is a separate backend for searching Auction items!
480 } # if
481 0 ▶ $iBids = 1 if ($oTDbids->as_text =~ m/SOLD/i);
Branch: 1 branch
BranchTrueFalseTotal
if $oTDbids->as_text =~ /SOLD/i 0 0 0
482 0 ▶ $iBids = $1 if ($oTDbids->as_text =~ m/(\d+)/);
Branch: 1 branch
BranchTrueFalseTotal
if $oTDbids->as_text =~ /(\d+)/ 0 0 0
483 0 my $W = $self->whitespace_pattern;
484 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($iBids =~ /\A$W*-$W*\Z/ or $iBids =~ /\A$W*\Z/) 0 0 0
Condition0%0/3
$iBids =~ /\A$W*-$W*\Z/ or $iBids =~ /\A$W*\Z/
l!l&&r!l&&!r
000
MC/DC0%0/2
$iBids =~ /\A$W*-$W*\Z/ or $iBids =~ /\A$W*\Z/
$iBids =~ /\A$W*-$W*\Z/ $iBids =~ /\A$W*\Z/
Truth table0%0/3
A or B
A= $iBids =~ /\A$W*-$W*\Z/B= $iBids =~ /\A$W*\Z/
ABresult
1X1
011
000
485 # Bid listed as hyphen means no bids:
486 ($iBids =~ m!\A$W*-$W*\Z!)
487 ||
488 # Bid listed as whitespace means no bids:
489 ($iBids =~ m!\A$W*\Z!)
490 )
491 {
492 0 $iBids = 0;
493 } # if
494 } # if
495 0 ▶ if ($iBids =~ m/NO/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($iBids =~ /NO/i) 0 0 0
496 {
497 0 $iBids = 0;
498 } # if
499 0 ▶ $iBids ||= 0;
Condition0%0/2
$iBids ||= 0
l!l
00
MC/DC0%0/1
$iBids ||= 0
$iBids
Truth table0%0/2
A
A= $iBids
Aresult
11
00
500 # print STDERR " DDD setting bid_count to =$iBids=\n";
501 0 $hit->bid_count($iBids);
502 0 return 1;
503 } # _parse_bids
504  
505 sub _parse_shipping
506 0 ▶ {
Subroutine _parse_shipping: not called CC=7 SCAR=40.3
507 0 my $self = shift;
508 0 my $oTD = shift;
509 0 my $hit = shift;
510 0 ▶ if ($oTD->attr('class') =~ m'\bebcCty\b')
Branch: 1 branch
BranchTrueFalseTotal
if ($oTD->attr("class") =~ /\bebcCty\b/) 0 0 0
511 {
512 # If we see this, we probably were searching for UK auctions
513 # but we ran off the bottom of the UK item list and ran
514 # into the list of international items.
515 0 return 0;
516 } # if
517 0 ▶ if (my $oChild = $oTD->look_down(_tag => 'span',
Branch: 1 branch
BranchTrueFalseTotal
if (my $oChild = $oTD->look_down("_tag", "span", "class", "ship")) 0 0 0
518 class => 'ship'))
519 {
520 # As of 2013-03, we need to separate out the price and the
521 # shipping for some flavors of eBay:
522 0 $oTD = $oChild;
523 } # if
524 0 my $iPrice = $oTD->as_text;
525 # I don't know why there are sometimes weird characters in there:
526 0 $iPrice =~ s!&Acirc;!!g;
527 0 $iPrice =~ s!Â!!g;
528 0 ▶ print STDERR " DDD raw shipping ===$iPrice===\n" if (DEBUG_COLUMNS || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
529 0 ▶ if ($iPrice =~ m/UNKNOWN/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($iPrice =~ /UNKNOWN/i) 0 0 0
530 {
531 # No shipping info provided:
532 0 return 1;
533 } # if
534 0 ▶ if ($iPrice =~ m/FREE/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($iPrice =~ /FREE/i) 0 0 0
535 {
536 0 $iPrice = 0.00;
537 } # if
538 0 ▶ return 0 if ($iPrice !~ m/\d/);
Branch: 1 branch
BranchTrueFalseTotal
unless $iPrice =~ /\d/ 0 0 0
539 0 $iPrice =~ s!&pound;!GBP!;
540 0 $hit->shipping($iPrice);
541 0 return 1;
542 } # _parse_shipping
543  
544 sub _parse_skip
545 0 ▶ {
Subroutine _parse_skip: not called CC=1 SCAR=6.9
546 0 my $self = shift;
547 0 my $oTD = shift;
548 0 my $hit = shift;
549 0 return 1;
550 } # _parse_skip
551  
552 sub _parse_enddate
553 0 ▶ {
Subroutine _parse_enddate: not called CC=14 SCAR=53.5
554 0 my $self = shift;
555 0 my $oTDdate = shift;
556 0 my $hit = shift;
557 0 my $sDate = 'unknown';
558 0 my ($s, $sDateTemp);
559 0 ▶ if (ref $oTDdate)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oTDdate) { } 0 0 0
560 {
561 0 $sDateTemp = $oTDdate->as_text;
562 0 $s = $oTDdate->as_HTML;
563 } # if
564 else
565 {
566 0 $sDateTemp = $s = $oTDdate;
567 }
568 0 ▶ print STDERR " DDD TDdate ===$s===\n" if (DEBUG_COLUMNS || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
569 # New version as of 2013-03:
570 0 ▶ if ($s =~ m/\bTIMEMS="(\d+)"/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\bTIMEMS="(\d+)"/i) 0 0 0
571 {
572 0 $sDate = $1;
573 0 $sDate = $self->_format_date(ParseDate(q{epoch }. int($sDate/1000)));
574 0 ▶ print STDERR " DDD sDate =$sDate=\n" if (DEBUG_COLUMNS || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
575 0 $hit->end_date($sDate);
576 # For backward-compatibility:
577 0 $hit->change_date($sDate);
578 0 return 1;
579 }
580 0 ▶ if (ref($oTDdate))
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oTDdate) 0 0 0
581 {
582 0 ▶ my $sClass = $oTDdate->attr('class') || q{};
Condition0%0/2
$oTDdate->attr('class') || ''
l!l
00
MC/DC0%0/1
$oTDdate->attr('class') || ''
$oTDdate->attr('class')
Truth table0%0/2
A
A= $oTDdate->attr('class')
Aresult
11
00
583 0 ▶ if ($sClass !~ m/\b(col3|ebcTim|ti?me)\b/)
Branch: 1 branch
BranchTrueFalseTotal
unless ($sClass =~ /\b(col3|ebcTim|ti?me)\b/) 0 0 0
584 {
585 # If we see this, we probably were searching for Buy-It-Now items
586 # but we ran off the bottom of the item list and ran into the list
587 # of Store items.
588 0 return 0;
589 # There is a separate backend for searching Store items!
590 } # if
591 } # if
592 0 ▶ print STDERR " DDD raw sDateTemp ===$sDateTemp===\n" if (DEBUG_DATES || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
593 0 ▶ if ($sDateTemp =~ m/---/)
Branch: 1 branch
BranchTrueFalseTotal
if ($sDateTemp =~ /---/) 0 0 0
594 {
595 # If we see this, we probably were searching for Buy-It-Now items
596 # but we ran off the bottom of the item list and ran into the list
597 # of Store items.
598 0 return 0;
599 # There is a separate backend for searching Store items!
600 } # if
601 # I don't know why there are sometimes weird characters in there:
602 0 $sDateTemp =~ s!&Acirc;!!g;
603 0 $sDateTemp =~ s!Â!!g;
604 0 $sDateTemp =~ s!<!!;
605 # Convert nbsp to regular space:
606 0 $sDateTemp =~ s!\240!\040!g;
607 0 $sDateTemp =~ s!Time\s+left:!!g;
608 0 $sDateTemp = $self->_process_date_abbrevs($sDateTemp);
609 0 ▶ print STDERR " DDD cooked sDateTemp ===$sDateTemp===\n" if (DEBUG_DATES || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
610 0 ▶ print STDERR " DDD official time =====$self->{_ebay_official_time}=====\n" if (DEBUG_DATES || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
611 0 my $date = DateCalc($self->{_ebay_official_time}, " + $sDateTemp");
612 0 ▶ print STDERR " DDD date ===$date===\n" if (DEBUG_DATES || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
613 0 $sDate = $self->_format_date($date);
614 0 ▶ print STDERR " DDD sDate ===$sDate===\n" if (DEBUG_DATES || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
615 0 $hit->end_date($sDate);
616 # For backward-compatibility:
617 0 $hit->change_date($sDate);
618 0 return 1;
619 } # _parse_enddate
620  
621  
622 =item result_as_HTML
623  
624 Given a WWW::SearchResult object representing an auction, formats it
625 human-readably with HTML.
626  
627 An optional second argument is the date format,
628 a string as specified for Date::Manip::UnixDate.
629 Default is '%Y-%m-%d %H:%M:%S'
630  
631 my $sHTML = $oSearch->result_as_HTML($oSearchResult, '%H:%M %b %E');
632  
633 =cut
634  
635 sub result_as_HTML
636 0 ▶ {
Subroutine result_as_HTML: not called CC=7 SCAR=40.3
Pod documented
637 0 my $self = shift;
638 0 ▶ my $oSR = shift or return '';
Branch: 1 branch
BranchTrueFalseTotal
my $oSR = shift() or return "" 0 0 0
639 0 ▶ my $sDateFormat = shift || q'%Y-%m-%d %H:%M:%S';
Condition0%0/2
shift() || '%Y-%m-%d %H:%M:%S'
l!l
00
MC/DC0%0/1
shift() || '%Y-%m-%d %H:%M:%S'
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
640 0 ▶ my $dateEnd = ParseDate($oSR->end_date) || q{};
Condition0%0/2
ParseDate($oSR->end_date) || ''
l!l
00
MC/DC0%0/1
ParseDate($oSR->end_date) || ''
ParseDate($oSR->end_date)
Truth table0%0/2
A
A= ParseDate($oSR->end_date)
Aresult
11
00
641 0 my $iItemNum = $oSR->item_number;
642 0 ▶ my $sSold = $oSR->sold
Branch: 1 branch
BranchTrueFalseTotal
$oSR->sold ? : 0 0 0
643 ? $cgi->font({color=>'green'}, 'sold') .q{; }
644 : $cgi->font({color=>'red'}, 'not sold') .q{; };
645 0 my $sBids = $self->_bidcount_as_text($oSR);
646 0 my $sPrice = $self->_bidamount_as_text($oSR);
647 0 my $sEndedColor = 'green';
648 0 my $sEndedWord = 'ends';
649 0 ▶ print STDERR " DDD compare end_date ==$dateEnd== to now\n" if (DEBUG_DATES || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
650 0 ▶ if (Date_Cmp($dateEnd, 'now') < 0)
Branch: 1 branch
BranchTrueFalseTotal
if (Date_Cmp($dateEnd, "now") < 0) 0 0 0
651 {
652 0 $sEndedColor = 'red';
653 0 $sEndedWord = 'ended';
654 } # if
655 0 my $sEnded = $cgi->font({ color => $sEndedColor },
656 UnixDate($dateEnd,
657 qq"$sEndedWord $sDateFormat"));
658 0 my $s = $cgi->b(
659 $cgi->a({href => $oSR->url}, $oSR->title),
660 $cgi->br,
661 qq{$sEnded; $sSold$sBids$sPrice},
662 );
663 0 $s .= $cgi->br;
664 0 $s .= $cgi->font({size => -1},
665 $cgi->a({href => qq{http://cgi.ebay.com/ws/eBayISAPI.dll?MakeTrack&item=$iItemNum}}, 'watch this item in MyEbay'),
666 );
667 # Format the entire thing as Helvetica:
668 0 $s = $cgi->font({face => 'Arial, Helvetica'}, $s);
669 0 return $s;
670 } # result_as_HTML
671  
672  
673 =back
674  
675 =head1 METHODS TO BE OVERRIDDEN IN SUBCLASSING
676  
677 You only need to read about these if you are subclassing this module
678 (i.e. making a backend for another flavor of eBay search).
679  
680 =over
681  
682 =cut
683  
684  
685 =item _get_result_count_elements
686  
687 Given an HTML::TreeBuilder object,
688 return a list of HTML::Element objects therein
689 which could possibly contain the approximate result count verbiage.
690  
691 =cut
692  
693 sub _get_result_count_elements
694 0 ▶ {
Subroutine _get_result_count_elements: not called CC=1 SCAR=6.9
695 0 my $self = shift;
696 0 my $tree = shift;
697 0 my @ao;
698 0 push @ao, $tree->look_down( # as of 2020-04
699 '_tag' => 'h1',
700 class => 'srp-controls__count-heading'
701 );
702 0 push @ao, $tree->look_down( # as of 2020-04
703 '_tag' => 'div',
704 class => 'srp-controls__control srp-controls__count'
705 );
706 0 push @ao, $tree->look_down( # as of 2015-06
707 '_tag' => 'span',
708 class => 'listingscnt'
709 );
710 0 push @ao, $tree->look_down( # as of 2020-03
711 '_tag' => 'span',
712 class => 'rcnt'
713 );
714 0 push @ao, $tree->look_down(
715 '_tag' => 'div',
716 class => 'fpcc'
717 );
718 0 push @ao, $tree->look_down(
719 '_tag' => 'div',
720 class => 'fpc'
721 );
722 0 push @ao, $tree->look_down(
723 # For basic search, as of 2013-03:
724 '_tag' => 'div',
725 class => 'clt'
726 );
727 0 push @ao, $tree->look_down(
728 '_tag' => 'div',
729 class => 'count'
730 );
731 0 push @ao, $tree->look_down(
732 '_tag' => 'div',
733 class => 'pageCaptionDiv'
734 );
735 0 push @ao, $tree->look_down( # for BySellerID as of 2010-07
736 '_tag' => 'div',
737 id => 'rsc'
738 );
739 0 return @ao;
740 } # _get_result_count_elements
741  
742  
743 =item _get_itemtitle_tds
744  
745 Given an HTML::TreeBuilder object,
746 return a list of HTML::Element objects therein
747 representing <TD> elements
748 which could possibly contain the HTML for result title and hotlink.
749  
750 =cut
751  
752 sub _get_itemtitle_tds
753 0 ▶ {
Subroutine _get_itemtitle_tds: not called CC=3 SCAR=24.8
754 0 my $self = shift;
755 0 my $tree = shift;
756 0 ▶ printf STDERR (" TTT this is Ebay::_get_itemtitle_tds\n") if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
757 0 my @ao = $tree->look_down(_tag => 'td',
758 class => 'details',
759 );
760 0 push @ao, $tree->look_down(_tag => 'td',
761 class => 'ebcTtl',
762 );
763 0 push @ao, $tree->look_down(_tag => 'td',
764 class => 'dtl', # This is for eBay auctions as of 2010-07
765 );
766 # This is for BuyItNow (thanks to Brian Wilson):
767 0 push @ao, $tree->look_down(_tag => 'td',
768 class => 'details ttl',
769 );
770 0 push @ao, $tree->look_down(_tag => 'div',
771 class => 's-item__info clearfix',
772 );
773 0 my $oDiv = $tree->look_down(_tag => 'div',
774 id => 'ResultSetItems',
775 );
776 0 ▶ if (ref $oDiv)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oDiv) 0 0 0
777 {
778 0 push @ao, $oDiv->look_down(_tag => 'td',
779 class => 'dtl dtlsp',
780 );
781 0 push @ao, $oDiv->look_down(_tag => 'h3',
782 class => 'lvtitle',
783 );
784 } # if
785 # printf STDERR (" DDD found %d itemtitle tags", scalar(@ao)) if (1 < $self->{_debug});
786 0 return @ao;
787 } # _get_itemtitle_tds
788  
789  
790 sub _parse_tree
791 0 ▶ {
Subroutine _parse_tree: not called CC=68 SCAR=84.5
792 0 my $self = shift;
793 0 my $tree = shift;
794 0 ▶ print STDERR " FFF Ebay::_parse_tree\n" if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
795 0 ▶ my $sTitle = $self->{response}->header('title') || '';
Condition0%0/2
$self->{'response'}->header('title') || ''
l!l
00
MC/DC0%0/1
$self->{'response'}->header('title') || ''
$self->{'response'}->header('title')
Truth table0%0/2
A
A= $self->{'response'}->header('title')
Aresult
11
00
796 0 my $qrTitle = $self->_title_pattern;
797 # print STDERR " DDD trying to match ==$sTitle== against ==$qrTitle==\n";
798 0 ▶ if ($sTitle =~ m!$qrTitle!)
Branch: 1 branch
BranchTrueFalseTotal
if ($sTitle =~ /$qrTitle/) 0 0 0
799 {
800 0 my ($sTitle, $iItem, $sDateRaw) = ($1, $2, $3);
801 0 my $sDateCooked = $self->_format_date($sDateRaw);
802 0 my $hit = new WWW::Search::Result;
803 0 $hit->item_number($iItem);
804 0 $hit->end_date($sDateCooked);
805 # For backward-compatibility:
806 0 $hit->change_date($sDateCooked);
807 0 $hit->title($sTitle);
808 0 $hit->add_url($self->{response}->request->uri);
809 0 $hit->description($self->_create_description($hit));
810 # print Dumper($hit);
811 0 push(@{$self->{cache}}, $hit);
812 0 $self->{'_num_hits'}++;
813 # $self->approximate_result_count(1);
814 0 return 1;
815 } # if
816  
817 # First, see if: there were zero results and eBay automatically did
818 # a spell-check and searched for other words (or searched for a
819 # subset of query terms):
820 0 my $oDIV = $tree->look_down(
821 _tag => 'div',
822 class => 'messages',
823 );
824 0 ▶ if (ref $oDIV)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oDIV) 0 0 0
825 {
826 0 my $sText = $oDIV->as_text;
827 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($sText =~ /0 results found for / and $sText =~ / so we searched for / || $sText =~ / so we removed keywords /) 0 0 0
Condition0%0/6
$sText =~ /0 results found for / and $sText =~ / so we searched for / || $sText =~ / so we removed keywords /
!ll&&!rl&&r
000
$sText =~ / so we searched for / or $sText =~ / so we removed keywords /
l!l&&r!l&&!r
000
MC/DC0%0/3
$sText =~ /0 results found for / and $sText =~ / so we searched for / || $sText =~ / so we removed keywords /
$sText =~ /0 results found for / $sText =~ / so we searched for / $sText =~ / so we removed keywords /
Truth table0%0/4
A and B or C
A= $sText =~ /0 results found for /B= $sText =~ / so we searched for /C= $sText =~ / so we removed keywords /
ABCresult
0XX0
1000
11X1
1011
828 ($sText =~ m/0 results found for /)
829 &&
830 (
831 ($sText =~ m/ so we searched for /)
832 ||
833 ($sText =~ m/ so we removed keywords /)
834 )
835 )
836 {
837 0 $self->approximate_result_count(0);
838 0 return 0;
839 } # if
840 } # if
841  
842 # See if our query was completely replaced by a similar-spelling query:
843 0 my $oLI = $tree->look_down(_tag => 'li',
844 class => 'ebInf',
845 );
846 0 ▶ if (ref $oLI)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oLI) 0 0 0
847 {
848 0 ▶ if ($oLI->as_text =~ m! keyword has been replaced !)
Branch: 1 branch
BranchTrueFalseTotal
if ($oLI->as_text =~ / keyword has been replaced /) 0 0 0
849 {
850 0 $self->approximate_result_count(0);
851 0 return 0;
852 } # if
853 } # if
854  
855 # See if our category-only query was replaced by a global query:
856 0 my $oP = $tree->look_down(_tag => 'p',
857 class => 'sm-md',
858 );
859 0 ▶ if (ref $oP)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oP) 0 0 0
860 {
861 0 my $s = $oP->as_text;
862 0 ▶ if (($s =~ m/0 results found in the/) && ($s =~ m/so we searched in all categories/))
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /0 results found in the/ and $s =~ /so we searched in all categories/) 0 0 0
Condition0%0/3
$s =~ /0 results found in the/ and $s =~ /so we searched in all categories/
!ll&&!rl&&r
000
MC/DC0%0/2
$s =~ /0 results found in the/ and $s =~ /so we searched in all categories/
$s =~ /0 results found in the/ $s =~ /so we searched in all categories/
Truth table0%0/3
A and B
A= $s =~ /0 results found in the/B= $s =~ /so we searched in all categories/
ABresult
0X0
100
111
863 {
864 0 return 0;
865 } # if
866 } # if
867  
868 0 my $iHits = 0;
869  
870 # The hit count is in one of these tags:
871 0 my @aoResultCountTagset = $self->_get_result_count_elements($tree);
872 0 ▶ if (scalar(@aoResultCountTagset) < 1)
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @aoResultCountTagset < 1) 0 0 0
873 {
874 0 warn " EEE no result_count_elements matched the HTML\n";
875 } # if
876 FONT:
877 0 foreach my $oFONT (@aoResultCountTagset)
878 {
879 0 my $s = $oFONT->as_text;
880 0 my $qr = $self->_result_count_pattern;
881 0 ▶ print STDERR (" DDD result_count try qr=$qr= against ==$s==\n") if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
882 0 ▶ if ($s =~ m/$qr/)
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /$qr/) { } 0 0 0
883 {
884 0 my $sCount = $1;
885 0 ▶ print STDERR " DDD matched ($sCount)\n" if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
886 # Make sure it's an integer:
887 0 $sCount =~ s!,!!g;
888 0 $self->approximate_result_count(0 + $sCount);
889 0 last FONT;
890 } # if
891 else
892 {
893 0 ▶ print STDERR " WWW DID NOT MATCH\n" if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
894 }
895 } # foreach FONT
896  
897 0 my $iApprox = $self->approximate_result_count();
898 0 ▶ if (defined($iApprox) && ($iApprox < 1))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $iApprox and $iApprox < 1) 0 0 0
Condition0%0/3
defined $iApprox and $iApprox < 1
!ll&&!rl&&r
000
MC/DC0%0/2
defined $iApprox and $iApprox < 1
defined $iApprox $iApprox < 1
Truth table0%0/3
A and B
A= defined $iApproxB= $iApprox < 1
ABresult
0X0
100
111
899 {
900 # Header says there are no results; return now and don't bother
901 # parsing the page:
902 0 return $iHits;
903 } # if
904  
905 # Recursively parse the stats telling how many items were found in
906 # each category:
907 0 my $oUL = $tree->look_down(_tag => 'ul',
908 class => 'categories');
909 0 ▶ $self->{categories} ||= [];
Condition0%0/2
$self->{"categories"} ||= []
l!l
00
MC/DC0%0/1
$self->{"categories"} ||= []
$self->{"categories"}
Truth table0%0/2
A
A= $self->{"categories"}
Aresult
11
00
910 0 ▶ $self->_parse_category_list($oUL, $self->{categories}) if ref($oUL);
Branch: 1 branch
BranchTrueFalseTotal
if ref $oUL 0 0 0
911  
912 # First, delete all the results that came from spelling variations:
913 0 my $oDiv = $tree->look_down(_tag => 'div',
914 id => 'expSplChk',
915 );
916 0 ▶ if (ref $oDiv)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oDiv) 0 0 0
917 {
918 # print STDERR " DDD found a spell-check ===", $oDiv->as_text, "===\n";
919 0 $oDiv->detach;
920 0 $oDiv->delete;
921 } # if
922 # The list of matching items is in a table. The first column of the
923 # table is nothing but icons; the second column is the good stuff.
924 0 my @aoTD = $self->_get_itemtitle_tds($tree);
925 0 ▶ unless (@aoTD)
Branch: 1 branch
BranchTrueFalseTotal
unless (@aoTD) 0 0 0
926 {
927 0 ▶ print STDERR " EEE did not find any result title tags\n" if $self->{_debug};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_debug"} 0 0 0
928 # use File::Slurp;
929 # write_file('no-results.html', $self->{response}->content);
930 } # unless
931 0 my $qrItemNum = qr{(\d{11,13})};
932 TD:
933 0 foreach my $oTDtitle (@aoTD)
934 {
935 # Sanity check:
936 0 ▶ next TD unless ref $oTDtitle;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oTDtitle 0 0 0
937 0 my $sTDtitle = $oTDtitle->as_HTML;
938 0 ▶ print STDERR " DDD try TDtitle ===$sTDtitle===\n" if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
939 # First A tag contains the url & title:
940 0 my $oA = $oTDtitle->look_down('_tag', 'a');
941 0 ▶ next TD unless ref $oA;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oA 0 0 0
942 0 ▶ my $sTitle = $oA->as_text || '';
Condition0%0/2
$oA->as_text || ''
l!l
00
MC/DC0%0/1
$oA->as_text || ''
$oA->as_text
Truth table0%0/2
A
A= $oA->as_text
Aresult
11
00
943 0 ▶ if ($sTitle eq '')
Branch: 1 branch
BranchTrueFalseTotal
if ($sTitle eq "") 0 0 0
944 {
945 0 my $oImg = $oA->look_down(_tag => 'img');
946 0 ▶ if (defined $oImg)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $oImg) 0 0 0
947 {
948 0 ▶ $sTitle = $oImg->attr('alt') || '';
Condition0%0/2
$oImg->attr('alt') || ''
l!l
00
MC/DC0%0/1
$oImg->attr('alt') || ''
$oImg->attr('alt')
Truth table0%0/2
A
A= $oImg->attr('alt')
Aresult
11
00
949 } # end if
950 } # end if
951 0 ▶ next TD if ($sTitle eq '');
Branch: 1 branch
BranchTrueFalseTotal
if $sTitle eq "" 0 0 0
952 0 ▶ print STDERR " DDD sTitle ===$sTitle===\n" if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
953 0 my $oURI = URI->new($oA->attr('href'));
954 # next TD unless ($oURI =~ m!ViewItem!);
955 0 ▶ next TD if ($oURI !~ m!$qrItemNum!);
Branch: 1 branch
BranchTrueFalseTotal
unless $oURI =~ /$qrItemNum/ 0 0 0
956 0 my $iItemNum = $1;
957 0 ▶ print STDERR " DDD iItemNum ===$iItemNum===\n" if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
958 0 my $iCategory = -1;
959 0 ▶ $iCategory = $1 if ($oURI =~ m!QQcategoryZ(\d+)QQ!);
Branch: 1 branch
BranchTrueFalseTotal
if $oURI =~ /QQcategoryZ(\d+)QQ/ 0 0 0
960 0 ▶ if ($oURI->as_string =~ m!QQitemZ(\d+)QQ!)
Branch: 1 branch
BranchTrueFalseTotal
if ($oURI->as_string =~ /QQitemZ(\d+)QQ/) 0 0 0
961 {
962 # Convert new eBay links to old reliable ones:
963 # $oURI->path('');
964 0 $oURI->path('/ws/eBayISAPI.dll');
965 0 $oURI->query("ViewItem&item=$1");
966 } # if
967 0 my $sURL = $oURI->as_string;
968 0 my $hit = new WWW::Search::Result;
969 0 $hit->add_url($self->_cleanup_url($sURL));
970 0 $hit->title($sTitle);
971 0 $hit->item_number($iItemNum);
972 # This is just to prevent undef warnings later on:
973 0 $hit->bid_count(0);
974 # The rest of the info about this item is in sister <LI> elements
975 # to the right:
976 0 my $sTag = 'li';
977 0 my @aoSibs = $oTDtitle->parent->look_down(_tag => $sTag);
978 # The parent itself is an <LI> tag:
979 0 shift @aoSibs;
980 0 ▶ warn " DDD before loop, there are ", scalar(@aoSibs), " sibling $sTag tags\n" if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
981 SIBLING_TD:
982 0 ▶ while (my $oTDsib = shift @aoSibs)
Branch: 1 branch
BranchTrueFalseTotal
if (my $oTDsib = shift @aoSibs) 0 0 0
983 {
984 0 ▶ next unless ref($oTDsib);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oTDsib 0 0 0
985 0 ▶ my $sColumn = $oTDsib->attr('class') || q{};
Condition0%0/2
$oTDsib->attr('class') || ''
l!l
00
MC/DC0%0/1
$oTDsib->attr('class') || ''
$oTDsib->attr('class')
Truth table0%0/2
A
A= $oTDsib->attr('class')
Aresult
11
00
986 0 my $s = $oTDsib->as_HTML;
987 0 ▶ if ($sColumn eq q{})
Branch: 1 branch
BranchTrueFalseTotal
if ($sColumn eq "") 0 0 0
988 {
989 0 ▶ warn " WWW auction info sibling has no class ==$s==" if (DEBUG_COLUMNS || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
990 0 ▶ if ($s =~ m/The item is listed as a Top Rated Plus item/)
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /The item is listed as a Top Rated Plus item/) 0 0 0
991 {
992 # Note: These items screw up the ByEndDate results because
993 # they appear out of order.
994 } # if
995 } # if
996 0 ▶ print STDERR " DDD looking at $sTag'$sColumn' ===$s===\n" if (DEBUG_COLUMNS || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
997 0 ▶ if ($sColumn =~ m'price')
Branch: 1 branch
BranchTrueFalseTotal
if ($sColumn =~ /price/) 0 0 0
998 {
999 0 ▶ next TD unless $self->_parse_price($oTDsib, $hit);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_parse_price($oTDsib, $hit) 0 0 0
1000 } # if
1001 0 ▶ if (($sColumn =~ m'bids') || ($sColumn =~ m'format'))
Branch: 1 branch
BranchTrueFalseTotal
if ($sColumn =~ /bids/ or $sColumn =~ /format/) 0 0 0
Condition0%0/3
$sColumn =~ /bids/ or $sColumn =~ /format/
l!l&&r!l&&!r
000
MC/DC0%0/2
$sColumn =~ /bids/ or $sColumn =~ /format/
$sColumn =~ /bids/ $sColumn =~ /format/
Truth table0%0/3
A or B
A= $sColumn =~ /bids/B= $sColumn =~ /format/
ABresult
1X1
011
000
1002 {
1003 # It is not a fatal error if there are no bids (i.e. buy-it-now)
1004 0 $self->_parse_bids($oTDsib, $hit);
1005 }
1006 0 ▶ if ($sColumn =~ m'shipping')
Branch: 1 branch
BranchTrueFalseTotal
if ($sColumn =~ /shipping/) 0 0 0
1007 {
1008 0 ▶ next TD if ! $self->_parse_shipping($oTDsib, $hit);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_parse_shipping($oTDsib, $hit) 0 0 0
1009 }
1010 0 ▶ if ($sColumn =~ m'end')
Branch: 1 branch
BranchTrueFalseTotal
if ($sColumn =~ /end/) 0 0 0
1011 {
1012 0 ▶ next TD if ! $self->_parse_enddate($oTDsib, $hit);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_parse_enddate($oTDsib, $hit) 0 0 0
1013 }
1014 0 ▶ if ($sColumn =~ m'time')
Branch: 1 branch
BranchTrueFalseTotal
if ($sColumn =~ /time/) 0 0 0
1015 {
1016 0 ▶ next TD if ! $self->_parse_enddate($oTDsib, $hit);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_parse_enddate($oTDsib, $hit) 0 0 0
1017 }
1018 0 ▶ if ($sColumn =~ m'country')
Branch: 1 branch
BranchTrueFalseTotal
if ($sColumn =~ /country/) 0 0 0
1019 {
1020 # This listing is from a country other than the base site
1021 # we're searching against. Throw it out:
1022 0 next TD;
1023 }
1024 0 ▶ if ($sColumn =~ m'extras')
Branch: 1 branch
BranchTrueFalseTotal
if ($sColumn =~ /extras/) 0 0 0
1025 {
1026 0 ▶ if ($iCategory < 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($iCategory < 0) 0 0 0
1027 {
1028 # We haven't found this item's category. Look for it here:
1029 0 $iCategory = $self->_parse_category($oTDsib);
1030 } # if
1031 } # if 'extras'
1032 # Any other class="" value will cause this <LI> to be ignored.
1033 0 ▶ print STDERR " DDD don't know how to process $sTag'$sColumn' ===$s===\n" if (DEBUG_COLUMNS || (1 < $self->{_debug}));
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
1034 } # while
1035 0 my $sDesc = $self->_create_description($hit);
1036 0 $hit->description($sDesc);
1037 0 $hit->category($iCategory);
1038 # Clean up / sanity check hit info:
1039 0 my ($enddate, $iBids);
1040 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (defined($enddate = $hit->end_date) and defined($iBids = $hit->bid_count) and 0 < $iBids and Date_Cmp($enddate, "now") < 0) 0 0 0
Condition0%0/9
defined($enddate = $hit->end_date) and defined($iBids = $hit->bid_count) and 0 < $iBids and Date_Cmp($enddate, "now") < 0
!ll&&!rl&&r
000
defined($enddate = $hit->end_date) and defined($iBids = $hit->bid_count) and 0 < $iBids
!ll&&!rl&&r
000
defined($enddate = $hit->end_date) and defined($iBids = $hit->bid_count)
!ll&&!rl&&r
000
MC/DC0%0/4
defined($enddate = $hit->end_date) and defined($iBids = $hit->bid_count) and 0 < $iBids and Date_Cmp($enddate, "now") < 0
defined($enddate = $hit->end_date) defined($iBids = $hit->bid_count) 0 < $iBids Date_Cmp($enddate, "now") < 0
Truth table0%0/5
A and B and C and D
A= defined($enddate = $hit->end_date)B= defined($iBids = $hit->bid_count)C= 0 < $iBidsD= Date_Cmp($enddate, "now") < 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1041 defined($enddate = $hit->end_date)
1042 &&
1043 defined($iBids = $hit->bid_count)
1044 &&
1045 (0 < $iBids) # Item got any bids
1046 &&
1047 (Date_Cmp($enddate, 'now') < 0) # Item is ended
1048 )
1049 {
1050 # Item must have been sold!?!
1051 0 $hit->sold(1);
1052 } # if
1053 0 ▶ print STDERR " DDD add hit to cache\n" if (1 < $self->{_debug});
Branch: 1 branch
BranchTrueFalseTotal
if 1 < $self->{"_debug"} 0 0 0
1054 0 push(@{$self->{cache}}, $hit);
1055 0 $self->{'_num_hits'}++;
1056 0 $iHits++;
1057  
1058 0 ▶ if ($self->approximate_result_count() <= $iHits)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->approximate_result_count <= $iHits) 0 0 0
1059 {
1060 # We've already scraped all the hits that eBay said there were.
1061 # Stop scraping, so that we don't return hits that are not an
1062 # exact match to the query but are just "related":
1063 0 last TD;
1064 } # if
1065  
1066 # Delete this HTML element so that future searches go faster?
1067 0 $oTDtitle->detach;
1068 0 $oTDtitle->delete;
1069 } # foreach TD
1070  
1071 0 undef $self->{_next_url};
1072 0 if (0)
1073 {
1074 # AS OF 2008-11 THE NEXT LINK CAN NOT BE FOLLOWED FROM PERL CODE
1075  
1076 # Look for a NEXT link:
1077 my @aoA = $tree->look_down('_tag' => 'a');
1078 TRY_NEXT:
1079 foreach my $oA (0, reverse @aoA)
1080 {
1081 next TRY_NEXT unless ref $oA;
1082 print STDERR " DDD try NEXT A ===", $oA->as_HTML, "===\n" if (1 < $self->{_debug});
1083 my $href = $oA->attr('href');
1084 next TRY_NEXT unless $href;
1085 # Looking backwards from the bottom of the page, if we get all the
1086 # way to the item list, there must be no next button:
1087 last TRY_NEXT if ($href =~ m!ViewItem!);
1088 if ($oA->as_text eq $self->_next_text)
1089 {
1090 print STDERR " DDD got NEXT A ===", $oA->as_HTML, "===\n" if 1 < $self->{_debug};
1091 my $sClass = $oA->attr('class') || '';
1092 if ($sClass =~ m/disabled/i)
1093 {
1094 last TRY_NEXT;
1095 } # if
1096 $self->{_next_url} = $self->absurl($self->{_prev_url}, $href);
1097 last TRY_NEXT;
1098 } # if
1099 } # foreach
1100 } # if 0
1101  
1102 # All done with this page.
1103 0 $tree->delete;
1104 0 return $iHits;
1105 } # _parse_tree
1106  
1107  
1108 =item _parse_category_list
1109  
1110 Parses the Category list from the left side of the results page.
1111 So far,
1112 this method can handle every type of eBay search currently implemented.
1113 If you find that it doesn't suit your needs,
1114 please contact the author because it's probably just a tiny tweak that's needed.
1115  
1116 =cut
1117  
1118 sub _parse_category_list
1119 0 ▶ {
Subroutine _parse_category_list: not called CC=9 SCAR=45.0
1120 0 my $self = shift;
1121 0 my $oTree = shift;
1122 0 my $ra = shift;
1123 0 my $oUL = $oTree->look_down(_tag => 'ul');
1124 0 my @aoLI = $oUL->look_down(_tag => 'li');
1125 CATLIST_LI:
1126 0 foreach my $oLI (@aoLI)
1127 {
1128 0 my %hash;
1129 0 ▶ next CATLIST_LI unless ref($oLI);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oLI 0 0 0
1130 0 ▶ if ($oLI->parent->same_as($oUL))
Branch: 1 branch
BranchTrueFalseTotal
if ($oLI->parent->same_as($oUL)) 0 0 0
1131 {
1132 0 my $oA = $oLI->look_down(_tag => 'a');
1133 0 ▶ next CATLIST_LI unless ref($oA);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oA 0 0 0
1134 0 my $oSPAN = $oLI->look_down(_tag => 'span');
1135 0 ▶ next CATLIST_LI unless ref($oSPAN);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oSPAN 0 0 0
1136 0 $hash{'Name'} = $oA->as_text;
1137 0 $hash{'ID'} = $oA->{'href'};
1138 0 $hash{'ID'} =~ /sacatZ([0-9]+)/;
1139 0 $hash{'ID'} = $1;
1140 0 my $i = $oSPAN->as_text;
1141 0 $i =~ tr/0-9//cd;
1142 0 $hash{'Count'} = $i;
1143 0 push @{$ra}, \%hash;
1144 } # if
1145 0 my @aoUL = $oLI->look_down(_tag => 'ul');
1146 CATLIST_UL:
1147 0 foreach my $oUL (@aoUL)
1148 {
1149 0 ▶ next CATLIST_UL unless ref($oUL);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oUL 0 0 0
1150 0 ▶ if($oUL->parent()->same_as($oLI))
Branch: 1 branch
BranchTrueFalseTotal
if ($oUL->parent->same_as($oLI)) 0 0 0
1151 {
1152 0 $hash{'Subcategory'} = ();
1153 0 $self->_parse_category_list($oLI, \@{$hash{'Subcategory'}});
1154 } # if
1155 } # foreach CATLIST_UL
1156 } # foreach CATLIST_LI
1157 } # _parse_category_list
1158  
1159  
1160 =item _process_date_abbrevs
1161  
1162 Given a date string,
1163 converts common abbreviations to their full words
1164 (so that the string can be unambiguously parsed by Date::Manip).
1165 For example,
1166 in the default English, 'd' becomes 'days'.
1167  
1168 =cut
1169  
1170 sub _process_date_abbrevs
1171 0 ▶ {
Subroutine _process_date_abbrevs: not called CC=1 SCAR=6.9
1172 0 my $self = shift;
1173 0 my $s = shift;
1174 0 $s =~ s!d! days!;
1175 0 $s =~ s!h! hours!;
1176 0 $s =~ s!m! minutes!;
1177 0 return $s;
1178 } # _process_date_abbrevs
1179  
1180  
1181 =item _next_text
1182  
1183 The text of the "Next" button, localized for a specific type of eBay backend.
1184  
1185 =cut
1186  
1187 sub _next_text
1188 0 ▶ {
Subroutine _next_text: not called CC=1 SCAR=6.9
1189 0 return 'Next';
1190 } # _next_text
1191  
1192  
1193 =item whitespace_pattern
1194  
1195 Return a qr// pattern to match whitespace your webpage's language.
1196  
1197 =cut
1198  
1199 sub whitespace_pattern
1200 1 ▶ {
Subroutine whitespace_pattern: called CC=1 SCAR=0.0
Pod documented
1201 # A pattern to match HTML whitespace:
1202 1 return qr{[\ \t\r\n\240]};
1203 } # whitespace_pattern
1204  
1205 =item _currency_pattern
1206  
1207 Return a qr// pattern to match mentions of money in your webpage's language.
1208 Include the digits in the pattern.
1209  
1210 =cut
1211  
1212 sub _currency_pattern
1213 1 ▶ {
Subroutine _currency_pattern: called CC=1 SCAR=0.0
1214 1 my $self = shift;
1215 # A pattern to match all possible currencies found in USA eBay
1216 # listings:
1217 1 my $W = $self->whitespace_pattern;
1218 1 return qr/(?:\$|C|EUR|GBP)$W*[0-9.,]+/;
1219 } # _currency_pattern
1220  
1221  
1222 =item _title_pattern
1223  
1224 Return a qr// pattern to match the webpage title in your webpage's language.
1225 Add grouping parenthesis so that
1226 $1 becomes the auction title,
1227 $2 becomes the eBay item number, and
1228 $3 becomes the end date.
1229  
1230 =cut
1231  
1232 sub _title_pattern
1233 0 ▶ {
Subroutine _title_pattern: not called CC=1 SCAR=6.9
1234 0 return qr{\A(.+?)\s+-\s+EBAY\s+\(ITEM\s+(\d+)\s+END\s+TIME\s+([^)]+)\)\Z}i; #
1235 } # _title_pattern
1236  
1237  
1238 =item _result_count_pattern
1239  
1240 Return a qr// pattern to match the result count in your webpage's language.
1241 Include parentheses so that $1 becomes the number (with commas is OK).
1242  
1243 =cut
1244  
1245 sub _result_count_pattern
1246 0 ▶ {
Subroutine _result_count_pattern: not called CC=1 SCAR=6.9
1247 0 return qr'([0-9,]+)\s+(active\s+)?(listing|item|matche?|result)s?(\s+found)?'i;
1248 } # _result_count_pattern
1249  
1250  
1251 5 1;
1252  
1253 __END__
↑ Summary Ebay/ByEndDate.pm »