HTTPS/Authenticated: Difference between revisions

From Rosetta Code
Content added Content deleted
(Perl)
 
m (Switch to header template)
Line 3: Line 3:
The goal of this task is to demonstrate HTTPS requests with authentication.
The goal of this task is to demonstrate HTTPS requests with authentication.


==[[Perl]]==
=={{header|Perl}}==
[[Category:Perl]]

use LWP::UserAgent qw();
use LWP::UserAgent qw();
my $ua = LWP::UserAgent->new;
my $ua = LWP::UserAgent->new;

Revision as of 05:32, 13 November 2007

Task
HTTPS/Authenticated
You are encouraged to solve this task according to the task description, using any language you may know.

The goal of this task is to demonstrate HTTPS requests with authentication.

Perl

use LWP::UserAgent qw();
my $ua = LWP::UserAgent->new;
my $netloc = 'http://www.buddhism-dict.net/cgi-bin/xpr-dealt.pl:80';
$ua->credentials(
   $netloc,
   'CJK-E and Buddhist Dictionaries', # basic realm
   'guest',  # user
   '',       # empty pw
);
my $response = $ua->get($netloc);
use WWW::Mechanize qw();
my $mech = WWW::Mechanize->new;
$mech->get('https://login.yahoo.com/');
$mech->submit_form(with_fields => {
    login         => 'XXXXXX',
    passwd        => 'YYYYYY',
    '.persistent' => 'y',  # tick checkbox
});