KarthikK has asked for the wisdom of the Perl Monks concerning the following question:
The above code is only to login. I am not sure how to get the session cookie from that login page and pass to the download page (code not written yet) I had also asked similar question at http://www.perlmonks.com/index.pl?node_id=645153 i got some responses but still I have a problem Is this scenario achievable in PERL? I am now learning this LWP and related modules since i am new to these Can you one help me in this regard? Thanks a lot in advance Regards, Karthik#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; use HTTP::Cookies; use HTTP::Request::Common qw(POST); use LWP::Debug qw(+); my $upload_url = 'https://mysite.com/fileupload.do'; my $login_url = 'https://mysite.com/login.do'; &postHTTPS(); sub postHTTPS { my $cookie_jar = HTTP::Cookies->new; #HTTP::Cookies->new(autosa +ve => 1) $cookie_jar->clear; my $action = POST ($login_url); my $ua = new LWP::UserAgent(keep_alive=>1,env_proxy => 0); $ua->proxy(['http','https'] => 'http://user:pwd@proxy_server:port' +); $ua->env_proxy(); $ua->cookie_jar($cookie_jar); my $request = new HTTP::Request ("GET" => $login_url ); my $response = $ua->request($action); if ($response->is_error()) { printf " %s\n", $response->status_line; print "https request error!\n"; }else { my $content = $response->content(); } if ( $response->is_success ) { # print $response->as_string; }else { #print $response->status_line; print "\nFailure!\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to authenticate and upload file to a secured server
by Corion (Patriarch) on Oct 18, 2007 at 16:03 UTC | |
|
Re: How to authenticate and upload file to a secured server
by ikegami (Patriarch) on Oct 18, 2007 at 16:49 UTC | |
by KarthikK (Sexton) on Oct 18, 2007 at 17:35 UTC | |
by ikegami (Patriarch) on Oct 18, 2007 at 17:57 UTC | |
by KarthikK (Sexton) on Oct 19, 2007 at 07:46 UTC |