Our corporate intranet boys at my client site have been busy making over the intranet site, and relaunched it on Wednesday. They also announced a competition with 5 star images at the top of certain pages. They offered a prize for a randomly chosen correct entry.

Of course, the temptation was too much for me to resist :). I learned all about how to do authentication with NTLM from LWP::UserAgent in the process. Here goes:(password suppressed to protect the innocent)

#!perl use strict; use warnings; use WWW::Mechanize; use HTML::TokeParser; my @todo = 'http://intranet'; my %seen = (@todo, 1); my $mech = WWW::Mechanize->new( keep_alive => 1 ); $mech->credentials('intranet:80','','CORP\\williami','censored'); while (my $url = shift @todo) { print "Visiting: $url\n"; $mech->get( $url); for ($mech->links) { my $link = $_->url_abs; push @todo, $link unless exists $seen{$link}; $seen{$link}++; } my $text = $mech->content; my $tp = HTML::TokeParser->new(\$text); while (my $tag = $tp->get_tag('img')) { print "Found image: ", $tag->[1]{src}, "\n"; } }

I came back from lunch to find that I had won. I'm curious about how many other correct entries there were though.

--
I'm Not Just Another Perl Hacker


In reply to Winning an Intranet competition with the aid of WWW::Mechanize by rinceWind

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!
  • 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:
    & &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.