This code basically grabs the
Newest Nodes XML, grabs each node and mails it...
#!/usr/bin/perl -w
use strict;
use XML::Parser;
use LWP::Simple;
use MIME::Lite;
my $parser = new XML::Parser ( Handlers => { Start => \&hdl_start, Cha
+r => \&hdl_char});
my $id = undef;
my %Nodes = ();
my $type = undef;
my $xml_stream = get("http://perlmonks.com/index.pl?node=newest+nodes+
+xml+generator");
$parser->parse($xml_stream);
foreach my $key (keys %Nodes)
{ my $page = get("http://perlmonks.com/index.pl?node_id=$key");
my $msg = MIME::Lite->new(
From =>'someone@somewhere.com',
To =>'someone@someplace.else.com',
Subject => "Perlmonks Node $Nodes{$key}",
Data => "Perlmonks Newest Nodes"
);
$msg->attach(Type =>'text/html',
Data =>$page);
$msg->send;
print "Sending part $Nodes{$key}\n";
}
sub hdl_start{
my ($p, $elt, %atts) = @_;
$type = $elt;
if ($type eq "NODE") { $id = $atts{node_id}; }
}
sub hdl_char {
my ($p, $str) = @_;
$str =~ s/\n//g;
if ($type eq "NODE" && $str) {
#print $id," => ",$str,"\n";
$Nodes{$id} = $str; }
}
Todo:
Ofcourse this could be used as base for an
NNTP link...
Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.