LWP cookies
Yan Yun-an <[email protected]>
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <[email protected]> |
Dear all,
I have troubles to download PDF file from www3.interscience.wiley.com
due to the cookie problem and the server complains like
"An error has occured because we were unable to send a cookie to your
web browser".
But I do use HTTP::Cookies. Please check the following for the
related code
my $ua = new LWP::UserAgent::FramesReady;
$ua->agent('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-
US; rv:1.9.2) Gecko/20100115 Firefox/3.6');
my $header = HTTP::Headers->new;
$header->header(Accept => "text/html,application/xhtml
+xml,application/xml;q=0.9,*/*;q=0.8");
my $cookie_jar = HTTP::Cookies->new(
file => "$ENV{HOME}/lwpcookies.txt",
autosave => 1,
ignore_discard => 0);
$ua->cookie_jar($cookie_jar);
$ua->default_headers ;
my $request = new HTTP::Request('GET', $url, $header);
$cookie_jar->add_cookie_header( $request );
my $response = $ua->request($request);
Also, when I fetch the URL http://www3.interscience.wiley.com/cgi-bin/
showEnv
with the above code. The HTTP_COOKIE content is missing, which shows
a problem of cookie acceptance.
Any solution is appreciated.
Thank you so much for your consideration.
Sincerely,
Yun-an