It works in Firefox, why not in $mech?
am 07.07.2006 22:31:14 von feedback--------------040204030406070907000900
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi everyone,
I have found the attached module to be useful when debugging.
In your code, you'll need
use WWW::Mechanize::Debug;
my $mech = WWW::Mechanize::Debug->new(...)
# when you're ready to $mech->click();
print "Request is" . $mech->simulated_click();
Compare this output from what TamperData or LiveHTTPHeaders shows you
when submitting the same request, and chances are, you've found your
problem :-)
Cheers,
Peter
--
Free Cellphone Monitoring Service
www.MinuteWatcher.com
--------------040204030406070907000900
Content-Type: text/plain;
name="Debug.pm"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="Debug.pm"
package WWW::Mechanize::Debug;
# (c) 2006 Peter Stevens. peter (dot) stevens (at) ch-open (dot) ch
# This module may be disutributed under the same conditions as perl itself.
# Debug routine(s?) for use with WWW::Mechanize
#
use strict;
use warnings FATAL => 'all';
our $VERSION = '0.03';
use base qw( WWW::Mechanize );
sub new {
my $class = shift;
my %args = @_;
my $self = $class->SUPER::new( %args );
return $self;
}
sub simulated_click {
# invoke this method where you would invoke $mech->click() to find out what will
# be sent to the server. Compare the results with Firefox/TamperData. If the
# requests are the same, the results should be the same.
#
my $this = shift;
my @args = @_ ;
my ( $f, $r, $t);
$f = $this->current_form(); # or one of its cousins - gives an HTML::Forms object
$r = $f->click( @args ); # gives HTTP::Request object
$r = $this->_modify_request( $r ); # v1.12 internal routine. Compatibility?
$t = $r->as_string(); # text of the request to compare with Tamper Data results.
return $t;
}
return 1;
--------------040204030406070907000900--