All pastes #149317 Raw Edit

grabRSS.pl

public text v1 · immutable
#149317 ·published 2006-08-25 18:28 UTC
rendered paste body
#!/usr/bin/perl

## Saves RSS feeds as file.0, file.1, file.2, etc...
## I couldn't really come up with a way to name the files more descriptively

require LWP::UserAgent;
 
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
$ua->agent('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'); 

## Put feeds here
@feeds = ("http://linuxgazette.net/lg.atom.xml",
          "http://www.fark.com/fark.rss",
          "http://rss.slashdot.org/Slashdot/slashdot");


for( $i=0; $i<@feeds; $i++){
    my $response = $ua->get("$feeds[$i]");
    if ($response->is_success) {
         open(OUT, ">>feed.$i") ;
         print OUT $response->content;
    }
    else {
        die $response->status_line;
    }
}