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

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.