AnyEvent-Net-Curl-Queued

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME

    AnyEvent::Net::Curl::Queued - Moo wrapper for queued downloads via
    Net::Curl & AnyEvent

VERSION

    version 0.049

SYNOPSIS

        #!/usr/bin/env perl
    
        package CrawlApache;
        use feature qw(say);
        use strict;
        use utf8;
        use warnings qw(all);
    
        use HTML::LinkExtor;
        use Moo;
    
        extends 'AnyEvent::Net::Curl::Queued::Easy';
    
        after finish => sub {
            my ($self, $result) = @_;
    
            say $result . "\t" . $self->final_url;
    
            if (
                not $self->has_error
                and $self->getinfo('content_type') =~ m{^text/html}
            ) {
                my @links;
    
                HTML::LinkExtor->new(sub {
                    my ($tag, %links) = @_;
                    push @links,
                        grep { $_->scheme eq 'http' and $_->host eq 'localhost' }
                        values %links;
                }, $self->final_url)->parse(${$self->data});
    
                for my $link (@links) {
                    $self->queue->prepend(sub {
                        CrawlApache->new($link);
                    });
                }
            }
        };
    
        1;
    
        package main;
        use strict;
        use utf8;
        use warnings qw(all);
    
        use AnyEvent::Net::Curl::Queued;
    
        my $q = AnyEvent::Net::Curl::Queued->new;
        $q->append(sub {
            CrawlApache->new('http://localhost/manual/')
        });
        $q->wait;

WARNING: GONE MOO!

    This module isn't using Any::Moose anymore due to the announced
    deprecation status of that module. The switch to the Moo is known to
    break modules that do extend 'AnyEvent::Net::Curl::Queued::Easy' /
    extend 'YADA::Worker'! To keep the compatibility, make sure that you
    are using MooseX::NonMoose:

        package YourSubclassingModule;
        use Moose;
        use MooseX::NonMoose;
        extends 'AnyEvent::Net::Curl::Queued::Easy';
        ...

    Or MouseX::NonMoose:

        package YourSubclassingModule;
        use Mouse;
        use MouseX::NonMoose;
        extends 'AnyEvent::Net::Curl::Queued::Easy';
        ...

    Or the Any::Moose equivalent:

        package YourSubclassingModule;
        use Any::Moose;
        use Any::Moose qw(X::NonMoose);
        extends 'AnyEvent::Net::Curl::Queued::Easy';
        ...

    However, the recommended approach is to switch your subclassing module
    to Moo altogether (you can use MooX::late to smoothen the transition):

        package YourSubclassingModule;
        use Moo;
        use MooX::late;
        extends 'AnyEvent::Net::Curl::Queued::Easy';
        ...

DESCRIPTION

    AnyEvent::Net::Curl::Queued (a.k.a. YADA, Yet Another Download
    Accelerator) is an efficient and flexible batch downloader with a
    straight-forward interface capable of:

      * create a queue;

      * append/prepend URLs;

      * wait for downloads to end (retry on errors).



( run in 0.492 second using v1.01-cache-2.11-cpan-39bf76dae61 )