jonjacobmoon has asked for the wisdom of the Perl Monks concerning the following question:
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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sending a POST and cookies via HTTP:Request::Common
by blm (Hermit) on Sep 28, 2002 at 08:20 UTC | |
by jonjacobmoon (Pilgrim) on Sep 28, 2002 at 18:19 UTC | |
|
Re: Sending a POST and cookies via HTTP:Request::Common
by cmmdrdata (Initiate) on Dec 23, 2003 at 00:09 UTC | |
by Anonymous Monk on Jan 08, 2004 at 17:55 UTC |