http://qs321.pair.com?node_id=170949

Not sure if this is a question better suited for the Perl Monks Discussion thread, but here it goes.

I want to write a Perl program that will automatically get information for me from PerlMonks.org, mainly my XP level. I noticed that a direct request to the XML ticker returns the level and values of the currently signed in individual.

Is there any way I can make a request for my information without signing in?

In order to get my level through the ticker, I have to send a GET query like this:

http://www.perlmonks.org/index.pl?node=XP%20xml%20ticker& user=newrisedesigns&passwd=**********&op=login

Because information like my level and XP are public, shouldn't there be a way to retrieve the information through the ticker without signing in?

John J Reiser
newrisedesigns.com

Replies are listed 'Best First'.
(jcwren) Re: PerlMonks XP XML Ticker
by jcwren (Prior) on Jun 02, 2002 at 00:41 UTC

    The reason you have to login is because it contains the number of votes left, which is personal information, so it requires authentication.

    The way I manage that is with cookies. Create a cookie and keep it local. Make a request to the page with the cookie loaded, and voila! It's as (in)secure as anything else on the site.

    None of these will help you, but check out What XML generators are currently available on PerlMonks? for other interesting tickers.

    --Chris

    e-mail jcwren

Re: PerlMonks XP XML Ticker
by Kanji (Parson) on Jun 02, 2002 at 20:49 UTC
    Because information like my level and XP are public, shouldn't there be a way to retrieve the information through the ticker without signing in?

    Is there any reason why you need to use the XML ticker? Sure it's convenient, but if you don't want to go through the hassle of automating logins there's no reason you can't use HTML::Parser and friends to rip the info out of non-ticker nodes, and this way you can add other monks to your ticker, too. ;^)

    #!/usr/bin/perl use strict; use warnings; use HTML::TableExtract; use LWP::Simple qw/ get /; my $monk = shift or die "$0 [monkname]\n"; my $url = "http://perlmonks.org/index.pl?node=${monk}"; my $html = HTML::TableExtract->new; $html->parse( get $url ); foreach my $table ( $html->table_states ) { foreach my $row ( $table->rows($table) ) { if ( $row->[0] eq 'Experience:' ) { print "$monk has $row->[1] XP. \n", "Give 'em \$1 and they might be able \n", "to buy a cup of coffee, too. \n"; exit; } } } print "No XP found ... perhaps ${monk} doesn't exist?\n";

        --k.


      I had thought about the HTML::Parser route, but it was ruled out by my webserver's lack of modules. I really should check into getting them installed (they don't support SSH or telnet).

      What I had planned on doing was have a small Perl program run on my webserver and return stats (my level, etc) from PerlMonks to my website. Just a simple side project.

      I'm going to stick with the XML XP Ticker mainly because it's short (easier to edit with a few regexps).

      Thanks for the HTML::Parser code. I was planning on reading up on HTML modules, and I think something along the lines of what you wrote would be a good starting point to learn and write some code that uses HTML::Parser and friends :)

      John J Reiser
      newrisedesigns.com