Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^4: Passing a cookie with LWP::UserAgent

by kyoshu (Curate)
on May 26, 2005 at 07:46 UTC ( #460540=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Passing a cookie with LWP::UserAgent
in thread Passing a cookie with LWP::UserAgent

you basicly need something like this: $ua->cookie_jar(HTTP::Cookies->new(file => "cookies.txt",autosave => 1));

some code from some of my script (to ilustrate how it works):

$ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "cookies.txt",autosave => 1));
my $req = HTTP::Request->new(POST => 'http://www.cacti.kobra.ktu.lt/index.php');
$req->content_type('application/x-www-form-urlencoded');
$req->content('login_username='.$login.'&login_password='.$passw.'&action=login');
my $res = $ua->request($req);
sleep(3);

my $req = HTTP::Request->new(GET => 'http://www.cacti.kobra.ktu.lt/tree.php?action=item_edit&parent_id=254&tree_
id=12&type_select=2');
my $res = $ua->request($req);
my $data = $res->as_string;


Comment on Re^4: Passing a cookie with LWP::UserAgent

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://460540]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2015-07-28 02:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (251 votes), past polls