Created
          April 26, 2011 00:52 
        
      - 
      
- 
        Save throughnothing/941581 to your computer and use it in GitHub Desktop. 
    script to download instapaper feed in epub format
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env perl | |
| use v5.10; | |
| use DateTime; | |
| use HTTP::Request; | |
| use LWP::UserAgent; | |
| use HTTP::Cookies; | |
| my $user = ''; | |
| my $pass = ''; | |
| my $now = DateTime->now; | |
| my ($y, $m, $d) = ($now->year, $now->month, $now->day); | |
| my $filename = "Instapaper-$m-$d-$y.epub"; | |
| my $file = "$ENV{HOME}/Downloads/$file"; | |
| if(-d '/Volumes/NOOK/My Files/Documents'){ | |
| # Nook stuff | |
| $file = "/Volumes/NOOK/My Files/Books/$filename"; | |
| } | |
| my $ua = LWP::UserAgent->new(cookie_jar => | |
| HTTP::Cookies->new(file => "/tmp/cookies.txt", autosave => 1)); | |
| my $req = HTTP::Request->new( POST => 'https://www.instapaper.com/user/login', | |
| [ 'Content-Type' => 'application/x-www-form-urlencoded' ], | |
| 'username=' . $user . '&password=' . $pass); | |
| # Log In | |
| my $res = $ua->request($req); | |
| $res->content =~ m/Logging in/g ? | |
| say 'Logged in' : ( say 'Couldn\'t Log In' and exit ); | |
| say "Downloading epub to $file..."; | |
| my $epub = $ua->request( | |
| HTTP::Request->new(GET => 'https://www.instapaper.com/epub') | |
| ); | |
| open my $fh, '>', $file; | |
| print $fh $epub->content; | |
| # Remove cookies | |
| unlink('/tmp/cookies.txt'); | 
Awesome, I'm glad this was useful for you! :)
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
Thank you very much for the script. I used it to put together a simple script to load the epub into my kobo (unwired actually):
https://github.com/caifara/Instapaper2Kobo