More POSTing fun
Colin Reid (Colin@predictivedialers.com)
Thu, 9 Apr 1998 10:28:45 -0700
OK, I'm having lots of fun POSTing to forms all over the place.
I'm attempting to write something that POSTs to a form whose results are a page
containing not one, not two, but three forms....then I want to fill out the
third form on THAT page, which bring up the actual results that I want to write
to a file. For the second form that I want to fill out, I just want to change
one option value and then submit....the problem is that the other contents of
that form are generated by filling out the first form...so I need help parsing
the page generated by the first form...taking that information and filling out
the next form should be easy....right?
The code I've attached just fills out the first form and prints out the results
so you can see what the next page looks like.
Thanks in advance to anyone who helps me out!
-- Colin Reid
colin@predictivedialers.com
------CAUTION! CODE AHEAD!!!--------
use HTTP::Request::Common;
use LWP::UserAgent;
$prefix = 'http://www.careerpath.com/cp/owa/';
$firsturl = $prefix . 'cp_ads_ocs.process_keyword_search';
$ua1 = LWP::UserAgent->new;
$ua1->agent("Mozilla/2.0 (compatible; MSIE 3.02; Update a; AK; Windows 95)");
my $res = $ua1->request(POST $firsturl,
[
session_id => '',
status => '',
categorylist => '96',
keywordtext => '',
keyword_option => 'ANY',
search_week => '3',
newspapers => '204',
newspapers => '264',
newspapers => '268',
newspapers => '1590',
newspapers => '960',
newspapers => '269',
submit => 'SEARCH',
]);
if ($res->is_success){
@firstresult = $res->content;
print @firstresult;
} else {
print "Could not post to ",$firsturl,"\n";
print "RESPONSE FROM SERVER WAS:\n";
print $res->as_string();
}