Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I thought of doing that myself as well. You could of course set up a cron job to just fetch the Selected Best Nodes to a timestamped file. I've set up the following cron job to archive that page into an SQLite database. It then prints out a reputation-sorted list of what it has already archived. That way, after a while, I'll have my own Top 5000 list.
#!/usr/bin/perl use strict; use warnings; use HTML::TableExtract; use LWP::Simple; use DBI; my $db_file = "best_nodes"; my $pm_site = "http://perlmonks.org/index.pl?node_id=%d"; my $make_table = ! -f $db_file; my $dbh = DBI->connect("dbi:SQLite:dbname=$db_file", "", "") or die "Can't connect to db: $DBI::errstr"; $dbh->do( qq[ create table nodes ( id int unique, title varchar(255), auth_id int, author varchar(255), rep int ) ]) if $make_table; my $html = get( sprintf $pm_site, 328478 ); my $te = HTML::TableExtract->new( headers => [ qw/Node Author Rep/ ], keep_html => 1 ); $te->parse($html); foreach my $row ($te->rows) { my ($node, $author, $rep) = @$row; my ($id) = $node =~ /\?node_id=(\d+)/; my ($auth_id) = $author =~ /\?node_id=(\d+)/; ($rep) = $rep =~ /(\d+)/; my ($title) = $node =~ m{>(.+?)</a>$}; ($author) = $author =~ m{>(.+?)</a>$}; $dbh->do("delete from nodes where id=?", undef, $id); $dbh->do("insert into nodes values (?,?,?,?,?)", undef, $id, $title, $auth_id, $author, $rep); } my $sth = $dbh->prepare( qq[ select id,title,auth_id,author,rep from nodes order by rep desc ]); $sth->execute; open my $fh, ">bestnodes.html" or die; print $fh "<table>\n"; while (my ($id, $title, $auth_id, $author, $rep) = $sth->fetchrow_arra +y) { $id = sprintf $pm_site, $id; $auth_id = sprintf $pm_site, $auth_id; print $fh qq[ <tr><td><a href="$id">$title</a></td> <td><a href="$auth_id">$author</a></td> <td>$rep</td></tr> ]; } print $fh "</table>\n";
Incidentally, this is my first experience with HTML::TableExtract, and it's just perfect for this job. Maybe I'll post the best nodes archive on my homepage once it gets big enough.

blokhead


In reply to Re: Selected Best Nodes Archive by blokhead
in thread Selected Best Nodes Archive by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others perusing the Monastery: (8)
    As of 2015-07-07 10:34 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (88 votes), past polls