Solved

Accessing password protected web URLs from a Perl script.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Question about @INC variable in perl 1 76
Bash one liner, start and end time calculation 13 124
combine multiple lines 2 79
Perl script to delete older files 6 98
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…

737 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