| 1 | package WWW::Mechanize::Plugin::Selector; | ||||||||||||||||||||
| 2 | 33 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 33 | our $VERSION= '0.24'; | |||||||||||||||||||
| 4 | 33 | ▶ | use HTML::Selector::XPath 'selector_to_xpath'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | =head1 SYNOPSIS | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | WWW::Mechanize::Plugin::Selector - CSS selector method for WWW::Mechanize | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =cut | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | =head1 ADDED METHODS | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head2 C<< $mech->selector( $css_selector, %options ) >> | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | my @text = $mech->selector('p.content'); | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | Returns all nodes matching the given CSS selector. If | ||||||||||||||||||||
| 21 | C<$css_selector> is an array reference, it returns | ||||||||||||||||||||
| 22 | all nodes matched by any of the CSS selectors in the array. | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | This takes the same options that C<< ->xpath >> does. | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | =cut | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | sub selector { | ||||||||||||||||||||
| 29 | 0 | ▶ | my ($self,$query,%options) = @_; | ||||||||||||||||||
|
Subroutine
selector: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 30 | 0 | ▶ | $options{ user_info } ||= "CSS selector '$query'"; | ||||||||||||||||||
|
Condition0%0/2
$options{"user_info"} ||= "CSS selector '${query}'"
MC/DC0%0/1
$options{"user_info"} ||= "CSS selector '${query}'"
$options{"user_info"}
Truth table0%0/2
A
A= $options{"user_info"}
| |||||||||||||||||||||
| 31 | 0 | ▶ | if ('ARRAY' ne (ref $query || '')) { | ||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
ref $query || ''
MC/DC0%0/1
ref $query || ''
ref $query
Truth table0%0/2
A
A= ref $query
| |||||||||||||||||||||
| 32 | 0 | $query = [$query]; | |||||||||||||||||||
| 33 | }; | ||||||||||||||||||||
| 34 | 0 | ▶ | my $root = $options{ node } ? './' : ''; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 35 | 0 | my @q = map { selector_to_xpath($_, root => $root) } @$query; | |||||||||||||||||||
| 36 | 0 | $self->xpath(\@q, %options); | |||||||||||||||||||
| 37 | }; | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 33 | 1; | |||||||||||||||||||