Debugging WWW::Mechanize scripts – printing requests and responses
by bigpresh on Mar.11, 2011, under Perl
Just for fast and easy reference really, but for easy debugging to find out the exact HTTP requests being sent and HTTP responses received by a web-scraping script using the excellent WWW::Mechanize, you can simply add:
$mech->add_handler("request_send", sub { shift->dump; return });
$mech->add_handler("response_done", sub { shift->dump; return });
This will cause all HTTP requests and responses to be output, so you can see exactly what’s happening.
January 14th, 2012 on 5:35 pm
Thank you for this hint.
January 31st, 2012 on 10:38 am
hi,
we’ll not get this module when we installed perl(i have installed perl 5.6.1) can u please tell me which version perl have it.
Thanks & regards
Deepthi
January 31st, 2012 on 10:45 am
@Deepthi – perl 5.6.1 is ancient (over ten years old) – I’d strongly recommend upgrading to a more recent version (5.10 or above, at least).
As for WWW::Mechanize, you can install it as you would any other CPAN module (using the cpan client, cpanm (cpanminus), or via your distro’s package tools.
For example, if you were using Debian, you could use e.g. apt-get install libwww-mechanize-perl.
February 3rd, 2012 on 1:27 pm
Thank you bigpresh
February 6th, 2012 on 4:41 am
hi ,
I have one doubt can we use for configure a file, where file is in html uses css and javascript.I tried but not configured