[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] LWP, HTTP & Netscape Cookies



Has anyone had luck using Netscape-style cookies from MacPerl?

I'm trying to write script that will get up early and download parts of the
newspaper for me.

I can retrieve the cookies from the MagicCookie file, but Cookies.pm is
failing to find the match between the URL in my HTTP::Request object and
the domain name hash buried in the Cookies object.

I can't make sense of all the levels of references to hashes to figure out
what's going on.  Reference to hashes as elements in hashes that you have
to look at by dereferencing.  Or something like that.

And I can't figure out why Cookies.pm is checking some odd paths.

Any clues?   In the meanwhile, I'll go re-read the "Reference" section in
Advanced Perl.

--Shawn


  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -

Here are the relevant lines:.  The print request line just says:
GET http://www.wsj.com/front.html.  No cookie is being attached.

Using Perl 5.2.0r4, Schinder's libwww-perl-5.35, and a spongey red wrist rest.


#!perl -w
use strict;
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request;


my $cookie_jar = HTTP::Cookies::Netscape->new (
	File=>"HD:System Folder:Preferences:Netscape f:MagicCookie");

my $ua = new LWP::UserAgent;

#substitute any site for which you have a cookie...
my $request = new HTTP::Request 'GET', 'http://www.wsj.com/front.html';

$cookie_jar->add_cookie_header($request);

print "REQUEST: ", $request->as_string(), "\n";

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




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch