Return to Snippet

Revision: 4736
at January 18, 2008 13:04 by eszpee


Initial Code
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
my $silent = 0; # set to 1 for no output on stdout
my $logindata = {
    'username' => 'fill in your username',
    'password' => 'fill in your password',
                };
my $loginurl = 'http://snipplr.com/login/';
my $backupurl = 'http://snipplr.com/zipbackup.php';
my $backupdir = '.';

my $ua = LWP::UserAgent->new;
$ua->cookie_jar({ file => "cookies.txt" });

print qq{get cookie from frontpage...} unless $silent;
my $devnull = $ua->get('http://snipplr.com/'); #get cookie
print qq{done.\n} unless $silent;

print qq{login as $$logindata{'username'}...} unless $silent;
my $loginresponse = $ua->post($loginurl, $logindata);
print qq{done.\n} unless $silent;

print qq{exporting snipplr_backup.zip...} unless $silent;
my $backupfile = $ua->get($backupurl);
open (KI, ">$backupdir/snipplr_backup.zip");
binmode KI;
print KI $backupfile->content;
close (KI);
print qq{done.\n} unless $silent;

Initial URL

                                

Initial Description
Suitable for backup scripts.

Initial Title
Backup your own snipplr.com snippets

Initial Tags
script, backup

Initial Language
Perl