Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Mail newest nodes

by Beatnik (Parson)
on Apr 25, 2001 at 18:01 UTC ( [id://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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2024-04-19 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found