Okay, I guess it is my week to get stumped. I just need another pair of eyes on this code, because I cannot for the life of me figure out what I am doing wrong. According to the docs it is right.

GOAL: trying to use LWP to signin to Amazon to retrieve data off their system

PROBLEM: they set a cookie AND at the same time, use the session id they send in the URL that is the action in the form.

ATTEMPTED METHOD: Use HTTP::Request::Common to POST the data and send the cookies at the same time hoping this will get through.

At this point, I am getting the error that "Can't locate object method "POST" via package "http://www.amazon.com/exec/obidos/flex-sign-in-done/" (perhaps you forgot to load "http://www.amazon.com/exec/obidos/flex-sign-in-done/"?) at ./goldbox.pl line 20" which I do not understand. I am not even sure if the cookies will be sent and the page handled properly, but I can't get past this stupid error message.

#!/usr/local/bin/perl -w use strict; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request; use HTTP::Headers; my $sessionid; my $browser = LWP::UserAgent->new; my $cookie_locale = "cookies.lwp"; my $cookie_jar = HTTP::Cookies->new( File => $cookie_locale, AutoSave => 1, ); my $email = 'xxxxxxx'; my $password = "xxxxxx"; my $url = "http://www.amazon.com/exec/obidos/flex-sign-in-done/"; my $req = $browser->request(POST $url, [ 'email' => $email, 'action' => 'sign-in checked', 'next-page' => 'recs/instant-recs-sign-in-standard.h +tml', 'password' => $password, 'method' => 'get', 'opt' => 'oa', 'page' => 'recs/instant-recs-register-standard. +html', 'response' => 'tg/stores/static/-/goldbox/index/', 'x' => '22', 'y' => '13', ] ); $cookie_jar->add_cookie_header($req); my $res = $browser->request($req); if ($res->is_success) { print $res->as_string; } else { my $cururl = $res->base->as_string; print "Error: " . $res->status_line . " $cururl\n"; }


I admit it, I am Paco.

In reply to Sending a POST and cookies via HTTP:Request::Common by jonjacobmoon

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.