Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Perl Monk, Perl Meditation
 
PerlMonks  

Mail newest nodes

by Beatnik (Parson)
on Apr 25, 2001 at 18:01 UTC ( #75451=CUFP: print w/ replies, xml ) Need Help??

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:
  • Skip duplicate nodes
Ofcourse this could be used as base for an NNTP link...

Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.

Comment on Mail newest nodes
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: CUFP [id://75451]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2014-04-16 06:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (414 votes), past polls