Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is this not the right way to test to see whether or not a page loaded via WWW::Mechanize? Every time I load this script it fails but I know the site I'm working with is loading because I load it in my browser.
use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->content($search_page); if (!$mech->success()) { print "ISite didn't respond"; exit; }

Replies are listed 'Best First'.
Re: www::mech success
by kyle (Abbot) on May 16, 2007 at 02:37 UTC

    With WWW::Mechanize, you need to first get the page before you can check for success or access its contents.

    use WWW::Mechanize; my $mech = WWW::Mechanize->new(); $mech->get($search_page); if (!$mech->success()) { die "ISite didn't respond"; } my $stuff = $mech->content();
Re: www::mech success
by marto (Cardinal) on May 16, 2007 at 08:06 UTC
    "Is this not the right way to test to see whether or not a page loaded via WWW::Mechanize?"

    This is a good reason to go back and read the documentation, FAQ and perhaps read a couple of the examples.

    Martin