Scrappy::Queue(3pm)

Scrappy::Queue3pm

Scrappy http request flow-control system

Usage

    #!/usr/bin/perl
    use Scrappy::Queue;
    my  $queue = Scrappy::Queue->new;
    
        $queue->add($url);
        
        while (my $url = $queue->next) {
            ... $queue->add(...);
        }

Version

version 0.94112090

Overview

Scrappy::Queue provides a system for saving URLs to a recordset/queue and iterating of them using the Scrappy framework.

Methods

list

The list method return the list of URLs in the queue. This is returned in list context.

    my  $queue = Scrappy::Queue->new;
    
    ...
    
    my  @list = $queue->list;

add

The add method adds new URLs to the queue. Duplicate URLs will be ignored.

    my  $queue = Scrappy::Queue->new;
        $queue->add($url);

clear

The clear method completely empties the queue and resets the cursor (loop position).

    my  $queue = Scrappy::Queue->new;
    
        $queue->add(...);
        $queue->add(...);
        $queue->add(...);
    
        $queue->clear;

reset

The reset method resets the cursor (loop position).

    my  $queue = Scrappy::Queue->new;
    
        $queue->add(...);
        $queue->add(...);
        $queue->add(...);
        
        while (my $url = $queue->next) {
            $queue->reset if ...; # beware the infinate loop
        }
        
        $queue->reset;

current

The current method returns the URL in the current loop position.

    my  $queue = Scrappy::Queue->new;
    
        $queue->add(...);
        $queue->add(...);
        $queue->add(...);
        
        while (my $url = $queue->next) {
            last if ...;
        }
        
        print 'great' if $url eq $queue->current;

next

The next method moves the cursor to the next loop position and returns the URL.

    my  $queue = Scrappy::Queue->new;
    
        $queue->add(...);
        $queue->add(...);
        $queue->add(...);
        
        while (my $url = $queue->next) {
            ...
        }

previous

The previous method moves the cursor to the previous loop position and returns the URL.

    my  $queue = Scrappy::Queue->new;
    
        $queue->add(...);
        $queue->add(...);
        $queue->add(...);
        
        while (my $url = $queue->next) {
            ...
        }
        
        print $queue->previous;

first

The first method moves the cursor to the first loop position and returns the URL.

    my  $queue = Scrappy::Queue->new;
    
        $queue->add(...);
        $queue->add(...);
        $queue->add(...);
        
        print $queue->first;

last

The last method moves the cursor to the last loop position and returns the URL.

    my  $queue = Scrappy::Queue->new;
    
        $queue->add(...);
        $queue->add(...);
        $queue->add(...);
        
        print $queue->last;

index

The index method moves the cursor to the specified loop position and returns the URL. The loop position is a standard array index position.

    my  $queue = Scrappy::Queue->new;
    
        $queue->add(...);
        $queue->add(...);
        $queue->add(...);
        
        print $queue->index(1);

cursor

The cursor method returns the current loop position.

    my  $queue = Scrappy::Queue->new;
        print $queue->cursor;

Releases

6 releases since Debian 8 (Jessie); the text changed 2 times.

  1. 8–10
  2. 11
  3. 12–13

Author

Al Newkirk <[email protected]>

From libscrappy-perl 0.94112090-3 in Debian 13 (Trixie). Parsed by carta from the page's man source.