http://www.perlmonks.org?node_id=1065319


in reply to Perl mechanize get Error!

What is your goal with this script? I have written a brief tutorial on using mechanize that can be found here: WWW::Mechanize Basics
If you need to do a lot of navigating on the site, I would recommend WWW::Mechanize::Firefox since it uses a lot of javascript. WWW::Mechanize and javascript don't get along too well. Also, try
$mech->dump_text;
I also recommend getting the firebug firefox extension and manually inspecting the page for each thing you want to access. For example, the url for 'Latest News' is http://www.truro-penwith.ac.uk/category/news/ which I determined by using the firebug extension..
So to go there, just do
$mech->get('http://www.truro-penwith.ac.uk/category/news/');
UPDATE: Also, simply:
my $mech = WWW::Mechanize->new(); $mech->get('http://www.truro-penwith.ac.uk/'); $mech->dump_text;
worked for me.. you don't need to do anything with headers..

Replies are listed 'Best First'.
Re^2: Perl mechanize get Error!
by Anonymous Monk on Jan 04, 2014 at 08:26 UTC
    Hi PerlSufi, You are great. Ok, Can you check this, https://thebigword-careers.irecruittotal.com/cac/SearchVacancy.aspx?EmploymentTypeID=0&Intranet=0 and give us a solution? Take it as a challenge. ;) Best Anonymous Monk
      I'm not really sure what the 'challenge' is? Do you want to be able to submit that form?
      use strict; use warnings; use WWW::Mechanize; #takes what vacancy to search as first argument on command line my $mech = WWW::Mechanize->new(); $mech->get("https://thebigword-careers.irecruittotal.com/cac/SearchVac +ancy.aspx?EmploymentTypeID=0&Intranet=0"); my $vacancy = $ARGV[0]; $mech->field( "ctl00$mvMintPP$ctl00$ContentPlaceHolder_Main$mvMintPP$ctl00$txbJobRef +", $vacancy); #(^^without plus sign occuring copied over) $mech->click_button(value => "Search Vacancies"); $mech->dump_text;
      ..might work..