It works in Firefox, why not in $mech?

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--

Re: It works in Firefox, why not in $mech?

am 10.07.2006 14:51:30 von philippe.bruhat

Le vendredi 07 juillet 2006 =E0 22:31, Peter Stevens =E9crivait:
>=20
> I have found the attached module to be useful when debugging.
>=20
> Compare this output from what TamperData or LiveHTTPHeaders shows you=20
> when submitting the same request, and chances are, you've found your=20
> problem :-)

The eg/logger.pl script included in the HTTP::Proxy distribution can be
useful too. Use it as a proxy both for your browser and your Mech script
and find out the differences.

No need to modify your script, just edit your HTTP_PROXY environment vari=
able.
No need to install extensions, just edit your browser's proxy settings.

--=20
Philippe "BooK" Bruhat

When you deal in weapons, there are no winners... only losers.
(Moral from Groo The Wanderer #31 (Ep=
ic))