blib/lib/WWW/Search/Yahoo/Japan.pm

filter: Statementstmt 48.0% 25 / 52 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 50.0% 6 / 12 Podpod 100% 1 / 1 totaltotal 37.2% 32 / 86 CC 11 SCAR 28.1
CC
11
Cov
35%
_a_is_next_link
42.0
_string_has_count
20.0
_result_list_items
6.0
CRAP 16.6
↑ Summary
1  
2 # $Id: Japan.pm,v 1.8 2008/12/25 18:55:43 Martin Exp $
3  
4 =head1 NAME
5  
6 WWW::Search::Yahoo::Japan - WWW::Search backend for searching Yahoo! Japan
7  
8 =head1 SYNOPSIS
9  
10 use WWW::Search;
11 my $oSearch = new WWW::Search('Yahoo::Japan');
12 my $sQuery = WWW::Search::escape_query("Iijima Ai");
13 $oSearch->native_query($sQuery);
14 while (my $oResult = $oSearch->next_result())
15 print $oResult->url, "\n";
16  
17 =head1 DESCRIPTION
18  
19 This class is a Yahoo! Japan specialization of L<WWW::Search>. It
20 handles making and interpreting searches on Yahoo! Japan
21 F<http://yahoo.co.jp>.
22  
23 This class exports no public interface; all interaction should
24 be done through L<WWW::Search> objects.
25  
26 =head1 OPTIONS
27  
28 If your query is in UTF-8, send option {ei => 'UTF-8'}
29 in the second argument to native_query().
30  
31 =head1 PRIVATE METHODS
32  
33 =cut
34  
35 package WWW::Search::Yahoo::Japan;
36  
37 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 2 ▶use Data::Dumper; # for debugging only
Subroutine BEGIN: called CC=1 SCAR=0.0
41 2 ▶use WWW::Search::Yahoo 2.377;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 2 ▶use base 'WWW::Search::Yahoo';
Subroutine BEGIN: called CC=1 SCAR=0.0
43  
44 our
45 2 $VERSION = do { my @r = (q$Revision: 1.8 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r };
46 2 our $MAINTAINER = 'Martin Thurn <mthurn@cpan.org>';
47  
48 sub _native_setup_search
49 3 ▶ {
Subroutine _native_setup_search: called CC=1 SCAR=0.0
50 3 my ($self, $sQuery, $rh) = @_;
51 3 $self->{'_options'} = {
52 p => $sQuery,
53 # Caller should send this option if desired:
54 # ei => 'UTF-8',
55 n => 100,
56 dups => 1,
57 };
58 3 $rh->{'search_base_url'} = 'http://search.yahoo.co.jp';
59 3 $rh->{'search_base_path'} = '/search';
60 3 return $self->SUPER::_native_setup_search($sQuery, $rh);
61 } # _native_setup_search
62  
63 sub _where_to_find_count
64 0 ▶ {
Subroutine _where_to_find_count: not called CC=1 SCAR=6.9
65 0 my %hash = (
66 _tag => 'div',
67 id => 'yschinfo',
68 );
69 0 return \%hash;
70 } # _where_to_find_count
71  
72 sub _string_has_count
73 0 ▶ {
Subroutine _string_has_count: not called CC=4 SCAR=30.0
74 0 my $self = shift;
75 0 my $s = shift;
76 0 ▶ return $1 if ($s =~ m{([,0-9]+)ä»¶\s+-\s+}i);
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /([,0-9]+)\303\203\302\244\303\202\302\273\303\202\302\266\s+-\s+/i 0 0 0
77 0 ▶ return $1 if ($s =~ m{([,0-9]+)\344\273\266\s+-\s+}i);
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /([,0-9]+)\344\273\266\s+-\s+/i 0 0 0
78 0 ▶ return $1 if ($s =~ m{([,0-9]+)&auml;&raquo;&para;\s+-\s+}i);
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /([,0-9]+)&auml;&raquo;&para;\s+-\s+/i 0 0 0
79 0 return -1;
80 } # _string_has_count
81  
82 sub _result_list_tags_OFF
83 0 ▶ {
Subroutine _result_list_tags_OFF: not called CC=1 SCAR=6.9
84 return (
85 0 _tag => 'div',
86 class => 'i',
87 );
88 } # _result_list_tags
89  
90  
91 sub _result_list_items
92 0 ▶ {
Subroutine _result_list_items: not called CC=2 SCAR=17.9
93 0 my $self = shift;
94 0 ▶ my $oTree = shift || die;
Condition0%0/2
shift() || die()
l!l
00
MC/DC0%0/1
shift() || die()
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
95 0 my @aoDIV = $oTree->look_down(
96 _tag => 'div',
97 class => 'web'
98 );
99 0 return @aoDIV;
100 } # _result_list_items
101  
102 sub _a_is_next_link
103 0 ▶ {
Subroutine _a_is_next_link: not called CC=6 SCAR=37.4
104 0 my $self = shift;
105 0 my $oA = shift;
106 0 ▶ return 0 unless (ref $oA);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $oA 0 0 0
107 0 my $s = $oA->as_text;
108 0 ▶ return 1 if ($s =~ m!次へ!i);
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /\303\246\302\254\302\241\303\243\302\201\302\270/i 0 0 0
109 0 ▶ return 1 if ($s =~ m!次\343\201\270!i);
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /\303\246\302\254\302\241\343\201\270/i 0 0 0
110 0 ▶ return 1 if ($s =~ m!\346\254\241\343\201\270!i);
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /\346\254\241\343\201\270/i 0 0 0
111 0 ▶ return 1 if ($s =~ m!次&atilde;&#129;&cedil;!i);
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /\303\246\302\254\302\241&atilde;&#129;&cedil;/i 0 0 0
112 } # _a_is_next_link
113  
114  
115 =head2 parse_details
116  
117 This is part of the basic WWW::Search::Yahoo mechanism.
118  
119 =cut
120  
121 sub parse_details
122 0 ▶ {
Subroutine parse_details: not called CC=2 SCAR=17.9
Pod documented
123 0 my $self = shift;
124 # Required arg1 = (part of) an HTML parse tree:
125 0 my $oLI = shift;
126 # Required arg2 = a WWW::SearchResult object to fill in:
127 0 my $hit = shift;
128 0 my $oTR = $oLI->look_down(_tag => 'div',
129 class => 'abs',
130 );
131 0 ▶ if (ref $oTR)
Branch: 1 branch
BranchTrueFalseTotal
if (ref $oTR) { } 0 0 0
132 {
133 0 $hit->description($oTR->as_text);
134 } # if
135 else
136 {
137 # warn
138 }
139 } # parse_details
140  
141 2 1;
142  
143 __END__
↑ Summary