Posted By

eszpee on 01/18/08


Tagged

snipplr script backup crawl LWPUserAgent


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

icecreamboyy


Backup your own snipplr.com snippets


 / Published in: Perl
 

Suitable for backup scripts.

  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
Posted By: SmpleJohn on January 18, 2008

Hmm... I wish I knew what I was doing with this. It looks useful. Any working examples or a tutorial for an idiot in this subject?

Posted By: eszpee on January 18, 2008

I'm afraid I don't really understand you question... this is a very simple script, it just logs in to snipplr.com and downloads your own snippets if you fill your login data in the beginning of the script.

I just needed it for my nightly backup script to save everything I have here.

You need to login to post a comment.