compare what FireFox gives you against what WWW::Mechanize or LWP::UserAgent give you.
I usually use HTTP::Proxy to do that comparison. Then I not only see what firefox sent, but what the Data::Dumper dump of the LWP object looks like.
The output in the query log shouldn't be used directly, but the sources it logs will prove the query can be done with LWP. The next step is just to figure out what the object you built by hand is missing.
use strict; use HTTP::Proxy qw(:log); my $proxy = new HTTP::Proxy( host => "localhost", port => 9999, logmask => HEADERS | STATUS, agent => new myagent, ); unlink "querylog.pl" if -f "querylog.pl"; $proxy->start; package myagent; use strict; use base 'LWP::UserAgent'; use Data::Dumper; local $Data::Dumper::Indent = 1; sub new { my $class = shift; my $this = $class->SUPER::new(@_); $this->timeout( 20 ); $this->agent("SniffProxy/0.9"); $this->requests_redirectable([qw(GET POST)]); return $this; } sub simple_request { my $this = shift; my ($req) = @_; if( $req->isa("HTTP::Request") ) { # and $req->method eq "POST" ) +{ open my $out, ">>", "querylog.pl" or die "couldn't open query + log: $!"; print $out "#############################\n# $req->{_method} $ +req->{_uri}\n# HTTP::Request {", "{{\n"; print $out "use strict;\n"; print $out "use URI::http;\n"; print $out "use HTTP::Request;\n"; print $out "use LWP::UserAgent;\n"; print $out "use HTTP::Request::Common qw(POST GET);\n\n"; print $out "my ", Dumper( $_[0] ); print $out "# }}", "}\n\n"; print $out "my \$ua = new LWP::UserAgent;\n"; print $out " \$ua->timeout( 10 );\n"; print $out " \$ua->requests_redirectable([qw(GET POST)]);\n" +; print $out "\n"; print $out "\$ua->simple_request( \$VAR1, \"content.dat\" );\n +"; close $out; } return $this->SUPER::simple_request(@_); }
-Paul
In reply to Re^2: LWP::UserAgent can't login to phpbb forum
by jettero
in thread LWP::UserAgent can't login to phpbb forum
by mnem0
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |