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

Cookie problems.

Thread Next
From:
Stefan Kruger
Date:
September 10, 2001 10:19
Subject:
Cookie problems.
Message ID:
Pine.BSF.4.10.10109101433150.1295-100000@ted.hq.inty.net
Hi there,

Can someone explain what I'm doing wrong here? 

Trying to set a cookie at a site (alltheweb.com) before
filling in a form. All works without the cookie, but with 
the cookie I get the error:

ted:~/perl/SiteSpider ->./test.pl
Can't locate object method "epath" via package "URI::http" at
/usr/local/lib/perl5/site_perl/5.6.0/HTTP/Cookies.pm line 110.

The cookie itself is the created by going to the site, letting
it set the cookie, and then copying it from the .netscape/cookies
file. Any ideas?

Thanks for any help.

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

use strict;

use HTML::Form;
use HTML::TokeParser;
use LWP::UserAgent;
use HTTP::Cookies;
use URI;

my @words = qw/perl python ruby java/;

my $frontpage = "http://www.alltheweb.com/";

my $ua = LWP::UserAgent->new;
my $jar = HTTP::Cookies::Netscape->new(
	      File => "alltheweb.cookie",
              AutoSave => 1,
	  );

$ua->cookie_jar($jar);

my $response = $ua->request(HTTP::Request->new('GET', $frontpage));
my $form = HTML::Form->parse($response->content, $frontpage);

# Search using alltheweb.com
foreach (@words) {
    $form->value(query => $_);

    # This line results in an error!
    my $resp = $ua->request($form->click);
}

__END__

-- 
Dr Stefan Kruger <stefan@inty.net> http://www.inty.net
Developer, Intelligent Network Technology Ltd
1700 Park Avenue, Aztec West, Bristol BS32 4UA, UK


Thread Next


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