develooper Front page | perl.libwww | Postings from March 2001

HTTP::Cookies (Urgent help needed)

From:
Waseem Aslam
Date:
March 9, 2001 03:28
Subject:
HTTP::Cookies (Urgent help needed)
Message ID:
20010309112844.45748.qmail@web12505.mail.yahoo.com
Hi 

i am trying to get cookie information from a remote
site (shoping catalog), however for this particular
site the HTTP::Cookie action has no effect. I have
tried the same code just changing the url on a number
of diffrent sites , cnn.com,mail.yahoo.com and
everyone.net they all give diffrent results , but the
site i want to work doesnt give anything (see code for
results of tests on all sites). 

i have listed my code below if someone can help 



#!/usr/local/bin/perl -w 

print "Content-type: text/html\n\n"; 


use LWP::Simple; 
use HTTP::Request::Common qw(POST); 
use HTTP::Request::Common qw(GET); 
use LWP::UserAgent; 
use HTTP::Cookies; 


### CNN .com - the cookies.txt is updated 

#$url = "http://www.cnn.com"; 

### Everyone.net the cookies.txt is not updated but
the cookie appears in windows/cookies 

#$url = "http://www.everyone.net"; 

##### Yahoo .com - the coookies.txt file is updated. 

#$url = "http://mail.yahoo.com"; 

### Test site using Actinic catalog - cookies.txt not
updated and cookie doesnt appear in windows/cookies 

$url =
"http://deepinthewoods.org/cgibin/ca000001.pl?PRODREF=23&RANDOM=NETQUOTEVAR:RANDOM&PATH=../www/acatalog/&PAGE=PRODUCT&SECTION_BLOB=A0004.cat";




$cookie_file = "/xxxxxxx/xxxx/cookies.txt"; 



$ua = LWP::UserAgent->new(); 
$ua->agent("Mozilla/4.51 [en]"); 



$cookie_jar = HTTP::Cookies->new( file =>
$cookie_file, ,ignore_discard => 1); 
$cookie_jar->load($cookie_file); 




$request = HTTP::Request->new(GET => $url); 


$cookie_jar->load; 

$cookie_jar->add_cookie_header($request); 



$response = $ua->request($request); 



$cookie_jar->extract_cookies($response); 


#print $cookie_jar->as_string() ; 

$cookie_jar->save($cookie_file); 



print $response->as_string(); 

Regards 

Waseem


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About