The goal of the script:
I have written a script to do basic authentication
and get a html document from a website (it's just a start of a script)
The problem:
The website want's me to accept cookies before i can
continue, so i added a cookiejar to the script so that LWP::UserAgent would accept cookies.
(i got that idea from this site: http://lwp.interglacial.com/ch11_01.htm)
But when i run the script i get the error page telling me to enable cookies in my browser so that i can continue.
What am i doing wrong?
The Error Page:#!/usr/local/bin/perl use strict; use warnings; use LWP; use HTML::TreeBuilder; use HTML::FormatText; use HTTP::Cookies; my $url = 'https://timetables.website.x.y.z/dir/'; my $cookie_jar = HTTP::Cookies->new(); my $browser = LWP::UserAgent->new(); $browser->cookie_jar($cookie_jar); $browser->agent('Mozilla/5.0 (compatible; MSIE 7.0; Windows N +T 6.0)'); $browser->from('my email'); $browser->protocols_allowed( ['https'] ); #User Credentials for access to the website.x.y.z realm. $browser->credentials( 'timetables.website.x.y.z:443', #website and port 'timetables.website.x.y.z', #realm 'user' => 'pass' # user credentials ); my $response = $browser->get($url); die "Error at $url\n ", $response->status_line, "\n Aborting" unless $response->is_success; print "OK", $response->content_type, " document!\n"; my $content = $response->decoded_content; my $html = new HTML::TreeBuilder; $html->parse($content); my $f = new HTML::FormatText(leftmargin => 0, rightmargin => 0); print $f->format($html);
Thanks in advance
UPDATE:
Thanks for the reactions so far.
I turned off javascript and i didn't get a warning page.
im now going to diagnose the problem with live headers in FF (thanks for the tip)
In reply to The Cookiejar Problem by dmusulin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |