?
Solved

Accessing password protected web URLs from a Perl script.

Posted on 2006-10-21
5
Medium Priority
?
178 Views
Last Modified: 2010-03-05
I'm a beginner at this but I have created simple Perl scripts to read from a web page using LWP::Simple  and LWP:UserAgent, however, I would now like to read a web page that I normally have to enter a username and password to get to.  How do I do this from a Perl script?

Thanks!
0
Comment
Question by:planetiowa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17782629
where is the username and password entered?
for some kinds of passwords you might do
perl -MLWP::Simple -e 'getprint "http://username:password@host/path"'
0
 
LVL 8

Expert Comment

by:Perl_Diver
ID: 17782686
http://search.cpan.org/~gaas/libwww-perl-5.805/lwpcook.pod#ACCESS_TO_PROTECTED_DOCUMENTS


ACCESS TO PROTECTED DOCUMENTS

Documents protected by basic authorization can easily be accessed like this:

  use LWP::UserAgent;
  $ua = LWP::UserAgent->new;
  $req = HTTP::Request->new(GET => 'http://www.linpro.no/secret/');
  $req->authorization_basic('aas', 'mypassword');
  print $ua->request($req)->as_string;
0
 

Author Comment

by:planetiowa
ID: 17793019
I tried the first suggestion but I got errors about an unrecognized host.  On the second response using the LWP::UserAgent method, this just returns an htm page with the username and password boxes again.  This is the base page I am trying to access:
http://cp.cr-cath.pvt.k12.ia.us/
0
 
LVL 8

Accepted Solution

by:
Perl_Diver earned 500 total points
ID: 17793547
0
 

Author Comment

by:planetiowa
ID: 17795417
Thnaks for the information.  I'll have to study that for awhile but it looks promising.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question