Gossamer Forum
Home : General : Perl Programming :

How to access a password protected website?

Quote Reply
How to access a password protected website?
Hi the following is my code to access a normal website without password.

use HTTP::Request::Common qw(POST);
use LWP::UserAgent;

$ua = LWP::UserAgent->new(); # create a new connection by using LWP module
my $address = "http://enterprise.i2r.a-star.edu.sg/.../patch/bin/files.cgi";
my $req = POST "$address", [ seqStat => "SAV", usr_seq => "try.seq", file => "$outfile", group => "all", minLen => 8, mismatch => 0, penalty => 100, boundary => 87.5];

But if the website is password protected, and of course I have the user id and password, how to do it in perl?

Thank you very much.
Quote Reply
Re: [Shaka875] How to access a password protected website? In reply to
Hi,

Have you tried this;

my $address = "http://username:password@enterprise.i2r.a-star.edu.sg/.../patch/bin/files.cgi";

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] How to access a password protected website? In reply to
Thank you very much Andy. I found that adding $req->authorization_basic('yangliang', 'stuyl'); will solve the problem.