Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Esteemed monks,

I am attempting to learn WWW::Mechanize in order to avoid paying for API access from a large financial institution. If my app can access their web interface securely then the API is unneccessary. The modules in libwww-perl and HTTP::Headers etc are fresh from CPAN. My sample code:

#!/usr/local/bin/perl use strict; use Carp; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new( autocheck => 1 ); my $url = 'https://secure.secret.com/login/login.cfm?someParam=foo'; $mech->get( $url ); print $mech->uri() . "\nStep 1 done. \n"; $mech->submit_form( form_number => 0, fields => { login => 'xxxxx', password => 'xxxx' } ); print $mech->uri() . "\n\nDone.";

The small sample code above produces the following output on the command line:

https://secure.secret.com/login/login.cfm?someParam=foo
Step 1 done.
Can't locate object method "remove_content_headers" via package "HTTP::Headers" at (eval 14) line 1.

So the get() works on the https url but the object we grab with submit_form() throws an error. Does anyone understand why this should be the case? The source looks like this:

sub remove_content_headers { my $self = shift; unless (defined(wantarray)) { # fast branch that does not create return object delete @$self{grep $entity_header{$_} || /^content-/, keys %$self} +; return; } my $c = ref($self)->new; for my $f (grep $entity_header{$_} || /^content-/, keys %$self) { $c->{$f} = delete $self->{$f}; } $c; }
Thanks very much for any advice!!

jg
_____________________________________________________
"The man who grasps principles can successfully select his own methods.
The man who tries methods, ignoring principles, is sure to have trouble.
~ Ralph Waldo Emerson

In reply to HTTP::Headers error when submitting form via WWW::Mechanize by jerrygarciuh

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-18 21:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found