I installed WWW:Mechanize by just downloading the code, I didn't get the zip which included mech-dump. I found the mech-dump on CPAN and it works like a champ. Thanks.
I found out why my post wasn't working. When I turned on LWP debugging I saw that the user name and password weren't included in the URI for the submit(). The debug output looked somethig like this.
I thought that since I did the get() with the user:pwd that the post would include it too. Do you know how I can fix this using Mechanize? Here is a code snippet, the first commented out block worked, the second doesn't.LWP::UserAgent::new: () LWP::UserAgent::proxy: http http://xxx.xx.xx.xx:8080 LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking www.site.com for cookies HTTP::Cookies::add_cookie_header: Checking .site.com for cookies HTTP::Cookies::add_cookie_header: Checking site.com for cookies HTTP::Cookies::add_cookie_header: Checking .com for cookies LWP::UserAgent::send_request: GET http://user:pwd@www.site.com/dir/_vt +i_bin/shtml.exe/post.htm?474 LWP::UserAgent::_need_proxy: Proxied to http://xxx.xx.xx.xx:8080 LWP::Protocol::http::request: () LWP::Protocol::collect: read 808 bytes LWP::Protocol::collect: read 1001 bytes LWP::UserAgent::request: Simple response: OK LWP::UserAgent::request: () HTTP::Cookies::add_cookie_header: Checking www.site.com for cookies HTTP::Cookies::add_cookie_header: Checking .site.com for cookies HTTP::Cookies::add_cookie_header: Checking site.com for cookies HTTP::Cookies::add_cookie_header: Checking .com for cookies LWP::UserAgent::send_request: POST http://www.site.com/dir/_vti_bin/sh +tml.exe/post.htm?474 LWP::UserAgent::_need_proxy: Proxied to http://xxx.xx.xx.xx:8080 LWP::Protocol::http::request: () LWP::Protocol::collect: read 397 bytes LWP::UserAgent::request: Simple response: Unauthorized
Thanks in advance,use strict; use warnings; use WWW::Mechanize; # Post article works! #my $mech = WWW::Mechanize->new(); #$mech ->get('http://user:pwd@www.site.com/dir/post.htm'); #$mech ->form_number(1); #$mech ->field('Subject', 'test'); #$mech ->field('Comments', 'test'); #$mech ->click(); #Reply article fails! LWP::Debug::level('+'); my $mech = WWW::Mechanize->new(); $mech->get('http://user:pwd@www.site.com/dir/_vti_bin/shtml.exe/post.h +tm?474'); $mech->form_number(1); $mech->field('Comments', 'woo-hoo'); my $response = $mech->submit(); if ($response->is_success) { print $response->content; } else { print $response->status_line."\n"; } exit 0;
In reply to Re: Re: Re: Re: Re: Re: Redirecting Forms with WWW::Mechanize
by Anonymous Monk
in thread Redirecting Forms with WWW::Mechanize
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |