Skip to content

Commit

Permalink
fixed a few more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 29, 2014
1 parent fc8d2cf commit d60d8f5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/Mojo/Collection.pm
Expand Up @@ -22,6 +22,7 @@ sub AUTOLOAD {
return $self->pluck($method, @_);
}

# DEPRECATED in Tiger Face!
sub DESTROY { }

sub c { __PACKAGE__->new(@_) }
Expand Down
8 changes: 4 additions & 4 deletions lib/Mojo/DOM.pm
Expand Up @@ -32,6 +32,7 @@ sub AUTOLOAD {
croak qq{Can't locate object method "$method" via package "$package"};
}

# DEPRECATED in Tiger Face!
sub DESTROY { }

sub all_contents { $_[0]->_collect(_all(_nodes($_[0]->tree))) }
Expand Down Expand Up @@ -419,7 +420,7 @@ Mojo::DOM - Minimalistic HTML/XML DOM parser with CSS selectors
# Find
say $dom->at('#b')->text;
say $dom->find('p')->text;
say $dom->find('p')->pluck('text');
say $dom->find('[id]')->pluck(attr => 'id');
# Iterate
Expand Down Expand Up @@ -504,7 +505,7 @@ L<Mojo::Collection> object containing these elements as L<Mojo::DOM> objects.
All selectors from L<Mojo::DOM::CSS/"SELECTORS"> are supported.
# List types of ancestor elements
say $dom->ancestors->type;
say $dom->ancestors->pluck('type');
=head2 append
Expand Down Expand Up @@ -627,8 +628,7 @@ All selectors from L<Mojo::DOM::CSS/"SELECTORS"> are supported.
my @headers = $dom->find('h1, h2, h3')->pluck('text')->each;
# Count all the different tags
my $hash = $dom->find('*')->pluck('type')
->reduce(sub { $a->{$b}++; $a }, {});
my $hash = $dom->find('*')->reduce(sub { $a->{$b->type}++; $a }, {});
# Find elements with a class that contains dots
my @divs = $dom->find('div.foo\.bar')->each;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/Message.pm
Expand Up @@ -492,7 +492,7 @@ make sure it is not excessively large, there's a 10MB limit by default.
# Use everything else Mojo::DOM has to offer
say $msg->dom->at('title')->text;
say $msg->dom->at('body')->children->type->uniq;
say $msg->dom->at('body')->children->pluck('type')->uniq;
=head2 error
Expand Down
3 changes: 1 addition & 2 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -381,8 +381,7 @@ Mojo::UserAgent - Non-blocking I/O HTTP and WebSocket user agent
say $ua->get('www.perl.org')->res->dom->at('title')->text;
# Scrape the latest headlines from a news site with CSS selectors
say $ua->get('blogs.perl.org')
->res->dom->find('h2 > a')->pluck('text')->shuffle;
say $ua->get('blogs.perl.org')->res->dom->find('h2 > a')->pluck('text');
# Search DuckDuckGo anonymously through Tor
$ua->proxy->http('socks://127.0.0.1:9050');
Expand Down

0 comments on commit d60d8f5

Please sign in to comment.