#!/usr/bin/perl -w # XP Grabber... use strict; use XML::Parser; use LWP::UserAgent; use URI::URL; use HTTP::Cookies; my $parser = new XML::Parser ( Handlers => { Start => \&hdl_start, End => \&hdl_end, Char => \&hdl_char, Default => \&hdl_def }); my $pm_user=''; #ofcourse fill you alias in here my $pm_password=''; #and your password in here my $WWWAgent = new LWP::UserAgent(); my $co=new HTTP::Cookies(file=>'./cookies.dat',autosave=>1,ignore_discard=>1); $WWWAgent->cookie_jar($co); my $url=new URI::URL 'http://www.perlmonks.org/index.pl'; $url->query_form(op => "login",node_id => "16046",user => $pm_user,passwd => $pm_password, expires=> "+10y"); my $WWWRequest = new HTTP::Request 'GET', $url->as_string() ; my $WWWResult = $WWWAgent->request($WWWRequest); die "Error logging in $WWWResult->code $WWWResult->message" if(!$WWWResult->is_success); my $cb_ticker = $WWWResult->content; $parser->parse($cb_ticker); sub hdl_start{ my ($p, $elt, %atts) = @_; if ($elt eq "XP") { open (XP,">/tmp/XP.db") || die $!; flock(XP,2); print XP "XP: ",$atts{xp},"\nXPs to next level: ",$atts{xp2nextlevel}; close(XP); } } sub hdl_end{ my ($p, $elt) = @_; } sub hdl_char { my ($p, $str) = @_; } sub hdl_def { }