| 1 | |||||||||||||
| 2 | =head1 NAME | ||||||||||||
| 3 | |||||||||||||
| 4 | WWW::Search::Ebay::Category - backend for returning entire categories on www.ebay.com | ||||||||||||
| 5 | |||||||||||||
| 6 | =head1 SYNOPSIS | ||||||||||||
| 7 | |||||||||||||
| 8 | use WWW::Search; | ||||||||||||
| 9 | my $oSearch = new WWW::Search('Ebay::Category'); | ||||||||||||
| 10 | # Category 1381 is Disney Modern Premiums: | ||||||||||||
| 11 | $oSearch->native_query(1381); | ||||||||||||
| 12 | while (my $oResult = $oSearch->next_result()) | ||||||||||||
| 13 | { print $oResult->url, "\n"; } | ||||||||||||
| 14 | |||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||
| 16 | |||||||||||||
| 17 | This class is a Ebay specialization of L<WWW::Search>. | ||||||||||||
| 18 | It handles making and interpreting Ebay searches | ||||||||||||
| 19 | F<http://www.ebay.com>. | ||||||||||||
| 20 | |||||||||||||
| 21 | This class exports no public interface; all interaction should | ||||||||||||
| 22 | be done through L<WWW::Search> objects. | ||||||||||||
| 23 | |||||||||||||
| 24 | =head1 NOTES | ||||||||||||
| 25 | |||||||||||||
| 26 | Returns the "first" 200 *auction* items in the given category. | ||||||||||||
| 27 | I'm not sure what exactly "first" means in this case; YMMV. | ||||||||||||
| 28 | |||||||||||||
| 29 | It is up to you to determine the number of the category you want. | ||||||||||||
| 30 | |||||||||||||
| 31 | See the NOTES section of L<WWW::Search::Ebay> for a description of the results. | ||||||||||||
| 32 | |||||||||||||
| 33 | =head1 METHODS | ||||||||||||
| 34 | |||||||||||||
| 35 | =cut | ||||||||||||
| 36 | |||||||||||||
| 37 | ##################################################################### | ||||||||||||
| 38 | |||||||||||||
| 39 | package WWW::Search::Ebay::Category; | ||||||||||||
| 40 | |||||||||||||
| 41 | 1 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 42 | 1 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 43 | |||||||||||||
| 44 | 1 | ▶ | use Carp; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 45 | 1 | ▶ | use Date::Manip; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 46 | 1 | ▶ | use base 'WWW::Search::Ebay'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 47 | |||||||||||||
| 48 | our | ||||||||||||
| 49 | 1 | $VERSION = 2.611; | |||||||||||
| 50 | |||||||||||||
| 51 | 1 | our $MAINTAINER = 'Martin Thurn <mthurn@cpan.org>'; | |||||||||||
| 52 | |||||||||||||
| 53 | 1 | ▶ | use constant DEBUG_FUNC => 0; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 54 | |||||||||||||
| 55 | sub _native_setup_search | ||||||||||||
| 56 | 2 | ▶ | { | ||||||||||
|
Subroutine
_native_setup_search: called CC=3 SCAR=12.3
| |||||||||||||
| 57 | 2 | my ($self, $native_query, $rhOptsArg) = @_; | |||||||||||
| 58 | 2 | ▶ | $rhOptsArg ||= {}; | ||||||||||
|
Condition50%1/2
$rhOptsArg ||= {}
MC/DC0%0/1
$rhOptsArg ||= {}
$rhOptsArg
Truth table50%1/2
A
A= $rhOptsArg
| |||||||||||||
| 59 | 2 | ▶ | unless (ref($rhOptsArg) eq 'HASH') | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 60 | { | ||||||||||||
| 61 | 0 | carp " --- second argument to _native_setup_search should be hashref, not arrayref"; | |||||||||||
| 62 | 0 | return undef; | |||||||||||
| 63 | } # unless | ||||||||||||
| 64 | $self->{_options} = { | ||||||||||||
| 65 | 2 | _ipg => 200, | |||||||||||
| 66 | _sacat => $native_query, | ||||||||||||
| 67 | }; | ||||||||||||
| 68 | 2 | return $self->SUPER::_native_setup_search($native_query, $rhOptsArg); | |||||||||||
| 69 | } # _native_setup_search | ||||||||||||
| 70 | |||||||||||||
| 71 | |||||||||||||
| 72 | sub _get_result_count_elements | ||||||||||||
| 73 | 0 | ▶ | { | ||||||||||
|
Subroutine
_get_result_count_elements: not called CC=1 SCAR=6.9
| |||||||||||||
| 74 | 0 | my $self = shift; | |||||||||||
| 75 | 0 | my $tree = shift; | |||||||||||
| 76 | 0 | my @ao; | |||||||||||
| 77 | 0 | push @ao, $tree->look_down( | |||||||||||
| 78 | _tag => 'h2', | ||||||||||||
| 79 | class => 'srp-controls__count-heading', | ||||||||||||
| 80 | ); | ||||||||||||
| 81 | 0 | return @ao; | |||||||||||
| 82 | } | ||||||||||||
| 83 | |||||||||||||
| 84 | sub _get_itemtitle_tds | ||||||||||||
| 85 | 0 | ▶ | { | ||||||||||
|
Subroutine
_get_itemtitle_tds: not called CC=3 SCAR=24.8
| |||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||
| 87 | 0 | my $tree = shift; | |||||||||||
| 88 | 0 | ▶ | printf STDERR (" TTT this is Category::_get_itemtitle_tds") if (1 < $self->{_debug}); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 89 | 0 | my @ao; | |||||||||||
| 90 | 0 | push @ao, $tree->look_down(_tag => 'div', | |||||||||||
| 91 | class => 's-item__image-section', | ||||||||||||
| 92 | ); | ||||||||||||
| 93 | 0 | ▶ | printf STDERR (" DDD found %d itemtitle tags", scalar(@ao)) if (1 < $self->{_debug}); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 94 | 0 | return @ao; | |||||||||||
| 95 | } # _get_itemtitle_tds | ||||||||||||
| 96 | |||||||||||||
| 97 | sub _preprocess_results_page_OFF | ||||||||||||
| 98 | 0 | ▶ | { | ||||||||||
|
Subroutine
_preprocess_results_page_OFF: not called CC=1 SCAR=6.9
| |||||||||||||
| 99 | 0 | my $self = shift; | |||||||||||
| 100 | 0 | my $sPage = shift; | |||||||||||
| 101 | # For debugging: | ||||||||||||
| 102 | 0 | print STDERR $sPage; | |||||||||||
| 103 | 0 | exit 88; | |||||||||||
| 104 | } # preprocess_results_page | ||||||||||||
| 105 | |||||||||||||
| 106 | sub _columns_use_SUPER | ||||||||||||
| 107 | 0 | ▶ | { | ||||||||||
|
Subroutine
_columns_use_SUPER: not called CC=1 SCAR=6.9
| |||||||||||||
| 108 | 0 | my $self = shift; | |||||||||||
| 109 | # This is for basic USA eBay: | ||||||||||||
| 110 | 0 | return qw( paypal bids price shipping enddate ); | |||||||||||
| 111 | } # _columns | ||||||||||||
| 112 | |||||||||||||
| 113 | |||||||||||||
| 114 | 1 | 1; | |||||||||||
| 115 | |||||||||||||
| 116 | =head1 SEE ALSO | ||||||||||||
| 117 | |||||||||||||
| 118 | To make new back-ends, see L<WWW::Search>. | ||||||||||||
| 119 | |||||||||||||
| 120 | =head1 CAVEATS | ||||||||||||
| 121 | |||||||||||||
| 122 | =head1 BUGS | ||||||||||||
| 123 | |||||||||||||
| 124 | Please tell the author if you find any! | ||||||||||||
| 125 | |||||||||||||
| 126 | =head1 AUTHOR | ||||||||||||
| 127 | |||||||||||||
| 128 | Maintained by Martin Thurn, C<mthurn@cpan.org>, L<http://www.sandcrawler.com/SWB/cpan-modules.html>. | ||||||||||||
| 129 | |||||||||||||
| 130 | =head1 LEGALESE | ||||||||||||
| 131 | |||||||||||||
| 132 | Copyright (C) 1998-2009 Martin 'Kingpin' Thurn | ||||||||||||
| 133 | |||||||||||||
| 134 | THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||||||||||||
| 135 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||||||||||||
| 136 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||
| 137 | |||||||||||||
| 138 | =cut | ||||||||||||
| 139 | |||||||||||||
| 140 | __END__ | ||||||||||||