Return to Snippet

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

Initial Code
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 = '';
my $backupurl = '';
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(''); #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} unless $silent;
my $backupfile = $ua->get($backupurl);
open (KI, ">$backupdir/");
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 snippets

Initial Tags
script, backup

Initial Language