previously posted wrong file...
right file now...
thanks...
#!/usr/bin/perl -w
use strict;
use HTML::TreeBuilder;
use LWP::UserAgent;
use URI::Escape;
use WWW::Mechanize;
use LWP::Simple;
use URI::URL;
use HTTP::Cookies;
my $ua = new LWP::UserAgent;
$ua->timeout(30);
$ua->agent("Mozilla/4.0 (compatible; MSIE 4.01; Windows95)" .
$ua->agent);
my $cookie_jar = HTTP::Cookies-> new(
file => "cookie.txt",
autosave => 1,
);
$ua->cookie_jar($cookie_jar);
# go ahead and get the selection page within the frame..
# use www::machanize
my $agent = WWW::Mechanize->new();
$agent->cookie_jar($cookie_jar);
#$agent->get($host_url);
my $host_url = "http://isis2.uiowa.edu/isis/chg_session/courses";
my $base_url = "http://isis2.uiowa.edu/isis/courses";
my $course_url = "https://isis2.uiowa.edu/isis/chg_session/doit";
#
# go ahead and fill/init the cookie_jar..
#
my $req = new HTTP::Request GET => $host_url;
$req->content_type('application/x-www-form-urlencoded');
my $res = $ua->request($req);
my $semester = "20043";
my $url = $course_url."?next=courses&session=".$semester;
$req = new HTTP::Request GET => ($url);
$res = $ua->request($req);
##############################################
#
# printing/testing key/header information
#
##############################################
foreach (keys %{$res->headers()})
{
print "$_ = ", $res->headers()->{$_}, "\n";
}
print "agent->location = ". $res->headers()->{'location'}. "\n";
print "agent->base = ". $res->base(). "\n";
print " testing\n";
print "cookie test...".$res->headers()->{'set-cookie'}."\n";
my @hdr = $res->headers()->{'set-cookie'};
my $key;
foreach $key (@hdr)
{
print " test zz = ". $key ."\n";
}
my %hdr = $res->headers()->{'set-cookie'};
foreach $key (keys (%hdr))
{
my $qq = $key;
print " test k = ". $hdr{$key} ."\n";
}
#print " ss ="[EMAIL PROTECTED]"\n";
print " xxxxx\n";
$cookie_jar->extract_cookies($res);
$cookie_jar->save();
die;
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
bruce
Sent: Wednesday, June 30, 2004 1:28 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: cookie question....
hi...
i'm trying to deal with recieving/transferring cookies. i have the following
code segment that works in another case, but i can't seem to figure out what
i've done wrong...
basically, i'm trying to extract/save the cookie. displaying the headers
indicates that i have a cookie/array, although i can't figure out how to
read it.. but using the extract_cookie method, doesn't seem to save the
cookie to my cookie.txt file...
there's something simple that i'm missing...
any comments/pointers/criticisms would be appreciated...
thanks
-bruce
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs