Im trying to use the Perl module Mechanize, but Im having a bit of trouble. The following piece of code is supposed to upload files to fileserve from google, but it doesnt work and it doesnt seem to return ANY errors, please help!
use strict;
use warnings;
use WWW::Mechanize;
my $resp;
my $insert_url = 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js';
use constant INDEX_SITE => 'fileserve.com';
use constant USERNAME => 'chuckaway';
use constant PASSWORD => 'chuckaway99';
my $mech = WWW::Mechanize->new();
my $url = 'http://www.fileserve.com/remote-upload.php';
$mech->get($url);
eval {
#print "# submit login $url\n";
$resp = $mech->submit_form(form_name => 'loginForm',
fields => { username => 'loginUserName',
password => 'loginUserPassword' }
);
die $resp->status_line unless $resp->is_success;
};
warn $@ if $@;
return if $@;
$resp = $mech->get($url);
eval {
$resp = $mech->submit_form(form_name => 'remoteUploadForm', fields => { urls => '$insert_url'});
};
Submitting the form with the password fails with Status 200, it returns the login form again. Have a look at your
submit_form
call, you do not fill in the credentials you set up earlier in the program.Use Wireshark or similar network sniffer to compare with a known good login request-response pair.