Hello everyone - long time reader (as google turns up perlmonks quite frequently) first time poster, as I'm frustratingly stuck. The Mechanize perl doc even recommends asking for assistance here, so I'm giving it a shot.
The problem: I'm attempting to use WWW::Mechanize to log into an apc network management card to scrape the temperature data contained in one of the pages. This should be an easy task... I would think.
I started by creating a super simple form on my own to verify I could submit a form with WWW::Mechanize. I quickly got this functional.
Now, with basic functional code, I used mech-dump to get the form information that I would need to submit (and verified this by recording logging into the interface with HTTP Watch). HTTP Watch also shows that after submitting the correct username, password, and language, you recieve a 303 response directing you to a new page that contains your session ID as part of the URI - so I MUST use the data returned by the 303 to get any further into the interface.
mech-dump returned this: login_username= (text) login_password= (password) prefLanguage=00000000 (option) *00000000/English submit=Log On (submit) <NONAME>=<UNDEF> (reset)
Given this information, I modified my (functional) test script to use the data provided by mech-dump and HTTP watch:
The problem at this point is, I always recieve a 500 back from the page. To make matters worse, I've tried to modify this script to submit to several other interfaces (IBM AMM, HP ILOM, etc) and none of them accept the data that I'm submitting, so it appears to be a problem with my perl.#!/usr/bin/perl use WWW::Mechanize; use Crypt::SSLeay; my $mech = WWW::Mechanize->new( autocheck => 0); $url="https://192.168.0.2"; $mech->get( $url ); print $mech->status; $mech->form_name('HashForm1'); $mech->field("login_username",'username'); $mech->field("login_password",'password'); $mech->field("prefLanguage",00000000); $mech->submit_form(); print "form submitted, reponse was ",$mech->status," printing header\n +"; my $response = $mech->response(); for my $key ( $response->header_field_names() ) { print $key, " : ", $response->header( $key ), "\n"; } exit;
Any help would be GREATLY appreciated, even if its just links to some extra documentation that I can read to find my own way (I've already tried the perdoc and the cookbook here: http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize/Cookbook.pod)
Thanks!
In reply to Seeking assistance with WWW::Mechanize Form Submission by tspang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |