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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Winning an Intranet competition with the aid of WWW::Mechanize
by merlyn (Sage) on May 13, 2005 at 16:10 UTC | |
|
Re: Winning an Intranet competition with the aid of WWW::Mechanize
by mrborisguy (Hermit) on May 13, 2005 at 15:47 UTC | |
|
Re: Winning an Intranet competition with the aid of WWW::Mechanize
by muba (Priest) on May 17, 2005 at 22:57 UTC | |
by TheStudent (Scribe) on May 18, 2005 at 00:13 UTC | |
by merzy (Scribe) on May 19, 2005 at 01:43 UTC |