in reply to Re: Re: Re: Re: Redirecting Forms with WWW::Mechanize
in thread Redirecting Forms with WWW::Mechanize

If that 474 is handed to you from MS, then you need to back up a level to the part of the transaction where you DO get that URL.

As to how mech-dump works, just call "mech-dump --forms URL"

xoxo,
Andy

  • Comment on Re: Re: Re: Re: Re: Redirecting Forms with WWW::Mechanize

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Redirecting Forms with WWW::Mechanize
by Anonymous Monk on Oct 09, 2003 at 20:12 UTC
    Thanks Andy,

    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.

    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
    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.
    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;
    Thanks in advance,
    monktim