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
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
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.