Forum Moderators: coopster & phranque

Message Too Old, No Replies

LWP POST Not Working

         

espeed

9:35 pm on Jul 1, 2004 (gmt 0)

10+ Year Member



I'm trying to write an LWP script that POSTs to [lending.etrade.com...] and returns mortgage rates, but I cannot get it to work. Instead of returning rates, it returns the same URL (as it should), but the page contains the form autopopulated with the supplied values.

The page uses a session ID, and I think I'm managing it properly. To rule out JavaScript interference, I turned off JavaScript in my browser, submitted the form, and it returned the rates so JavaScript isn't required. What am I missing? Here's a code snippet...thanks.

# First request to init session ID
my $url = "https://lending.etrade.com/e/t/mortgage/expressratequote";
my $req = HTTP::Request->new(GET => $url);
$req->user_agent('Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)');
my $res = $ua->request($req);
$req = $res->request();
$cookie_jar->extract_cookies($res);

# Actual Form Request
$req = HTTP::Request->new(POST => $url);
$req->content_type('application/x-www-form-urlencoded');
$req->content($curl->equery);
$req->referer($url);
$req->user_agent('Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)');
$cookie_jar->add_cookie_header($req);
$res = $ua->request($req);
$req = $res->request();
print $res->content();

VectorJ

12:41 am on Jul 2, 2004 (gmt 0)

10+ Year Member



For something like this I generally use WWW:Mechanize. It's a sub class of LWP and I think you'll find it very easy to use, especially when posting to forms. Sorry I couldn't address the problem directly, but I hope this helps.

flashfan

4:57 pm on Jul 2, 2004 (gmt 0)

10+ Year Member



can you try http instead of https? https might be the killer.