Aside from the obvious consistency issues, I ran into this when programming my
custom random node program. In order to customize which categories got displayed, I had to determine the category
from the page in exactly the manner you describe above.
I even had to differentiate between discussions and catacombs based on the existence of a shaded table... Ewww, how long before that assumption breaks?
In short, a consistant category label would have made this project *much* easier, and would improve its robustness in the future.
Update: Although it's quite ugly, here is the relevant snippet.
my $html = get("http://perlmonks.com/index.pl?op=randomnode");
($node) = $html =~ /\blastnode_id=(\d+)/;
my ($title) = $html =~ /<title>([^>]+)<\/title>/i;
my ($author) = $html =~ /\bby\s*<A HREF[^>]+>([^<]+)<\/A>/i;
if ($title eq $author) {
$section = 'Homenode';
($homenodexp) = $html =~ /Experience:.*?<B>(\d+)/;
} elsif ($author eq 'perlnewsbot') {
$section = 'News';
} else {
($section) = $html =~ /\b(?:go|back)\s+(?:to\s+)?(?:see\s+more\s+)
+?<A HREF=\
"\/index.pl\?node=(Seekers|Meditations|Craft|Cool|Perl)/i;
$section = 'Poetry' if $section eq 'Perl';
$section ||= $html =~ /bgcolor="CCCCCC"/i ? 'Code' : '';
$section ||= 'Disc';
}
-Blake
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.