Solved

Accessing password protected web URLs from a Perl script.

Posted on 2006-10-21
5
175 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 125 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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

729 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