[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

open URL in perl

Posted on 2006-07-19
8
Medium Priority
?
2,160 Views
Last Modified: 2010-07-27
Hi experts,

I’m currently testing hundreds of URL. All URL require the same username and password to open.
My question is how can I open an URL in Perl?
Once I successfully access the URL, how can I let Perl fill in the username and password?
Any way, all I want to do is to write a little Perl script to test these URLs instead of me going through hundreds of them manually.

Thanks a lot  
0
Comment
Question by:jamewang
[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
  • 3
  • 2
8 Comments
 
LVL 17

Accepted Solution

by:
mjcoyne earned 2000 total points
ID: 17137686
Sounds like a job for WWW::Mechanize (see http://search.cpan.org/dist/WWW-Mechanize/lib/WWW/Mechanize.pm).

From the synopsis:

"WWW::Mechanize, or Mech for short, helps you automate interaction with a website. It supports performing a sequence of page fetches including following links and submitting forms. Each fetched page is parsed and its links and forms are extracted. A link or a form can be selected, form fields can be filled and the next page can be fetched. Mech also stores a history of the URLs you've visited, which can be queried and revisited."

Example:

    use WWW::Mechanize;
    my $mech = WWW::Mechanize->new();

    $mech->get( $url );

    $mech->follow_link( n => 3 );
    $mech->follow_link( text_regex => qr/download this/i );
    $mech->follow_link( url => 'http://host.com/index.html' );

    $mech->submit_form(
        form_number => 3,
        fields      => {
            username    => 'mungo',
            password    => 'lost-and-alone',
        }
    );

    $mech->submit_form(
        form_name => 'search',
        fields    => { query  => 'pot of gold', },
        button    => 'Search Now'
    );
0
 

Author Comment

by:jamewang
ID: 17150814
Thanks mjcoyne, but how do i get around the password prompt. I don't think that count as the first form in the page.
0
 
LVL 17

Expert Comment

by:mjcoyne
ID: 17150886
Are the username and password fields part of an HTML page?
0
 

Author Comment

by:jamewang
ID: 17150900
I don't think so, It prompts me to enter the username and password
0
 
LVL 17

Expert Comment

by:mjcoyne
ID: 17151306
You'll need to tell me what is generating the password prompt -- is it in a pop-up window?  Is it being triggered by HTML, JavaScript, .htaccess files, or what?

See also http://search.cpan.org/~prashant/Win32-IEAutomation-0.5/lib/Win32/IEAutomation.pm.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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

649 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