Backup your own snipplr.com snippets


/ Published in: Perl
Save to your folder(s)

Suitable for backup scripts.


Copy this code and paste it in your HTML
  1. #!/usr/bin/perl
  2. use strict;
  3. use LWP::UserAgent;
  4. my $silent = 0; # set to 1 for no output on stdout
  5. my $logindata = {
  6. 'username' => 'fill in your username',
  7. 'password' => 'fill in your password',
  8. };
  9. my $loginurl = 'http://snipplr.com/login/';
  10. my $backupurl = 'http://snipplr.com/zipbackup.php';
  11. my $backupdir = '.';
  12.  
  13. my $ua = LWP::UserAgent->new;
  14. $ua->cookie_jar({ file => "cookies.txt" });
  15.  
  16. print qq{get cookie from frontpage...} unless $silent;
  17. my $devnull = $ua->get('http://snipplr.com/'); #get cookie
  18. print qq{done.\n} unless $silent;
  19.  
  20. print qq{login as $$logindata{'username'}...} unless $silent;
  21. my $loginresponse = $ua->post($loginurl, $logindata);
  22. print qq{done.\n} unless $silent;
  23.  
  24. print qq{exporting snipplr_backup.zip...} unless $silent;
  25. my $backupfile = $ua->get($backupurl);
  26. open (KI, ">$backupdir/snipplr_backup.zip");
  27. print KI $backupfile->content;
  28. close (KI);
  29. print qq{done.\n} unless $silent;

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.