Hi,
I've run into a strange problem. I've tested this code on 3 boxes:
Linux Testing Server:
debian sarge
PERL 5.8.4-8sarge3
libwww-perl 5.803-4
www-mechanize 1.12-2
crypt-ssleay 0.51-3
W32 Testing Server:
XP PRO 2002 SP2
ActiveState PERL v5.8.6 built for MSWin32-x86-multi-thread
libwww-perl 5.801
www-mechanize 0.72
crypt-ssleay 0.51
Client's Server:
XP PRO 2002 SP2
ActiveState PERL 5.8.0 built for MSWin32-x86-multi-thread
libwww-perl 5.68
www-mechanize 0.72
crypt-ssleay 0.51
It works everywhere except of course the client's server...
While debugging I've found that everything works up until this request:
$mech->submit_form(
form_number => 1,
fields => { 'password' => $self->{password} },
);
After that request
$mech->uri returns the same url as before the request, but
$mech->content(...) is empty.
The strange part is that this works fine and they are both very similar https posts:
$mech->submit_form(
form_name => 'login',
fields => { 'input-login-email' => $self->{account}, 'password'
+ => $self->{password} },
);
I've tried everything I can think of to get it working... Using:
**************
$mech->field(...info...);
$mech->click();
**************
$mech->submit(...info...);
**************
$mech->request( $request); # with a proper post request...
**************
And 100 other variations.
**************
They all work on the testing servers, but not the production... I tried using regular LWP requests to get through the security before I even started using WWW:Mechanize, I couldn't even get that working on the testing servers. This is not my first rodeo, but I'm stumped. All I can think of is that the LWP version is breaking the code. Anybody else have any other ideas? Upgrading PERL/LWP can only happen as a last resort.
Here is a snippet of the relevant parts of the offending code:
if ($self->{location} eq 'us'){
login_us($self) unless $self->{logged_in};
$mech->get('https://s1.amazon.com/exec/varzea/subst/your-account/m
+anage-your-seller-account.html/ref=ya_hp_az_2/');
}
elsif ($self->{location} eq 'uk'){
login_uk($self) unless $self->{logged_in};
$mech->get('http://s1.amazon.co.uk/exec/varzea/subst/your-account/
+manage-your-seller-account.html/ref=ya_hp_az_2/');
}
$mech->follow_link(text_regex => qr/View your Amazon Payments account
+and billing history/i);
$mech->follow_link(text_regex => qr/View your Amazon Payments account
+summary/i);
$mech->submit_form(
form_number => 1,
fields => { 'password' => $self->{password} },
);
$mech->follow_link(url_regex => qr/vg=1&ve=6&vf=4/i);
sub login_us{
my $self = shift;
print "Performing US LOGIN...\n";
$mech->get('http://www.amazon.com/');
$mech->follow_link(text_regex => qr/your account/i);
$mech->follow_link(text_regex => qr/Your seller account/i);
$mech->submit_form(
form_name => 'login',
fields => { 'input-login-email' => $self->{account}, 'p
+assword' => $self->{password} },
);
$self->{logged_in} = 1;
return $mech->content(base_href => [undef]);
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.