Scrappy::Session(3pm)
π Scrappy::Session β the manual page, but make it cute π
okay bestie, so this is Scrappy::Session(3pm), straight out of the User Contributed Perl Documentation, and we're gonna get you fluent in it, no cap. π«Ά
β¨ NAME β¨
Scrappy::Session β Scrappy Scraper Session Handling π
πΈ VERSION πΈ
version 0.94112090 β yes that's the actual version string, iconic, don't question it π
π¦ SYNOPSIS π¦
#!/usr/bin/perl
use Scrappy::Session;
my $session = Scrappy::Session->new;
-f 'scraper.sess' ?
$session->load('scraper.sess');
$session->write('scraper.sess');
$session->stash('foo' => 'bar');
$session->stash('abc' => [('a'..'z')]);
like literally copy that vibe and you're already cooking π
π DESCRIPTION π
Scrappy::Session provides YAML-Based session file handling for saving recorded data across multiple execution using the Scrappy framework. so your scraper remembers stuff between runs. it's giving persistent memory, but make it YAML β¨
π ATTRIBUTES π
here's the list of object attributes that every single Scrappy::Session instance is walking around with, periodt.
π« auto_save
the auto_save attribute is a boolean and it decides whether your stash data gets automatically saved to the session file on update. like, do you want it to just do the thing, or do you want to be in control? main character choice fr fr.
my $session = Scrappy::Session->new;
$session->load('scraper.sess');
$session->stash('foo' => 'bar');
# turn auto-saving off
$session->auto_save(0);
$session->stash('foo' => 'bar');
$session->write; # explicit write
see how she turns it off and then writes on purpose? that's the explicit write, bestie π
π« file
the file attribute gets/sets the filename of the current session file. getter AND setter, she does both, versatile queen.
my $session = Scrappy::Session->new;
$session->load('scraper.sess');
$session->write('scraper.sess.bak');
$session->file('scraper.sess');
π₯ METHODS π₯
π load
the load method reads in a session file, and it returns its data in the structure it was saved-in. same shape going in as coming out, we love consistency π«Ά
my $session = Scrappy::Session->new;
my $data = $session->load('scraper.sess');
π stash
the stash method accesses the stash object, which is the lil container used to store data that's gonna get written to the session file. it's the holding pen, the vibe vault π
my $session = Scrappy::Session->new;
$session->load('scraper.sess');
$session->stash('foo' => 'bar');
$session->stash('abc' => [('a'..'z')]);
$session->stash->{123} = [(1..9)];
not me using both the method-call style AND the hash-deref style in the same snippet β she contains multitudes π
π write
the write method writes out a session file. it saves the data stored in the session stash and it returns the data written upon completion. so you get receipts, always ask for receipts π§Ύβ¨
my $session = Scrappy::Session->new;
$session->stash('foo' => 'bar');
$session->stash('abc' => [('a'..'z')]);
$session->stash->{123} = [(1..9)];
my $data = $session->write('scraper.sess');
π AUTHOR π
Al Newkirk <awncorp@cpan.org> β shoutout to the author, absolute legend, no notes π«‘
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2010 by awncorp.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
so basically: it's free, you can share it, you can remix it, same terms as Perl 5 itself. slay. π
aaaand that's the whole page bestie!! this beauty was documented for perl v5.34.0 and the page is dated 2022-06-17, and the manual name is Scrappy::Session(3pm) in case you forgot where you were. now go stash something and write it out, i'm obsessed with you π
πβ¨π¦πΈπ
π¦ where this page comes from
- debian bookworm: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libscrappy-perl 0.94112090-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms