Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Querying Saints in our Book

by hdb (Monsignor)
on Jul 29, 2015 at 18:03 UTC ( [id://1136774]=note: print w/replies, xml ) Need Help??


in reply to Querying Saints in our Book

Here is my Perl-script to monitor my own progress:

use strict; use warnings; use LWP::UserAgent; use HTML::TableExtract; use DateTime; die "usage: perl $0 monk password seconds\n" unless $#ARGV == 2; my ( $monk, $pass, $secs ) = @ARGV; print "Querying the monastery once every $secs seconds for monk $monk\ +'s reputation.\n"; $secs = 10 if $secs < 10; while(1) { my $ua = LWP::UserAgent->new; $ua->agent("PMReputation"); my $res = $ua->post( 'http://perlmonks.org/?', {"node_id" => "3559", "op" => "login", "lastnode_id" => "3559", "user" => $monk, "passwd" => $pass, "expires" => "+10y", "length" => "500",} ); die "Cannot enter the monastery ($res->status_line).\n" unless $res- +>is_success; my $te = HTML::TableExtract->new( headers => [ '#', 'User', 'Experie +nce', 'Level', 'Writeups', 'User Since', 'Last Here' ] ); $te->parse( $res->content ); my $writeups = 0; my $exp = 0; my $level = ""; my $rank = 0; my $total = 0; foreach my $ts ($te->tables) { foreach my $row ($ts->rows) { $total = $row->[0]; if( $row->[1] eq $monk ) { ($rank, $exp, $level, $writeups) = @$row[0,2,3,4]; } } } my $now = DateTime->now( time_zone => 'Europe/Berlin' ); my $text = $now->dmy.",".$now->hms.": $level $monk has experience of + $exp and $writeups write ups, Saint $rank/$total.\n"; print $text; if( open my $log, ">>", "narcissistic.txt" ) { print $log $text; close $log; } sleep( $secs-3 ); }

Replies are listed 'Best First'.
Re^2: Querying Saints in our Book
by choroba (Cardinal) on Jul 29, 2015 at 21:42 UTC
    Less frequent data can be obtained by other methods described here and here.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re^2: Querying Saints in our Book
by chacham (Prior) on Jul 29, 2015 at 18:20 UTC

    Yeah, perl would be nice, however, a script is easier to install, and seems easier for ad hoc queries.

    If only there were perlscript.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1136774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 14:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found