Results 1 to 8 of 8

Thread: Perl Mechanize programming

  1. #1
    Join Date
    Dec 2005
    Location
    Bourenmouth, Dorset
    Beans
    32
    Distro
    Ubuntu 12.04 Precise Pangolin

    Perl Mechanize programming

    Hi

    I access a password protected website and have to repeat a task several times.

    I am hoping this can this be automated with the use of the Mechanize perl script.

    Is there a way to record the selections I make on the site that can then be used as a template for a perl script?

    I am new to perl programming and use Ubuntu for my desktop.

    Cheers

    Kevin

  2. #2
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Perl Mechanize programming


  3. #3
    Join Date
    Dec 2005
    Location
    Bourenmouth, Dorset
    Beans
    32
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Perl Mechanize programming

    ok

  4. #4
    Join Date
    Feb 2008
    Location
    Mine goes to 11
    Beans
    Hidden!

    Re: Perl Mechanize programming

    My friends can handle their Linux.

  5. #5
    Join Date
    Dec 2005
    Location
    Bourenmouth, Dorset
    Beans
    32
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Perl Mechanize programming

    THanks for the info.

    The site does not want to let me in unless I am doing something wrong.

    In Mechanize shell:
    get http://websiteIwanttovisit.com
    Retrieving http://websiteIwanttovisit.com(200)
    fillout # interactive form for login and password
    submit
    200
    browse # Open results in a web browser takes me back to the login page

    In the message console it reports a Javascript check login
    From before Ubuntu 10.10

  6. #6
    Join Date
    Feb 2013
    Beans
    Hidden!

    Re: Perl Mechanize programming

    TBH, I never used WWW::Mechanize as all my automated login needs are covered with something as simple as:
    Code:
    #!/usr/bin/perl -w
    
    use Net::Netrc;
    use URI;
    use LWP::Simple;
    
    ($login, $password, undef) = Net::Netrc->lookup('example.com')->lpa;
    
    $uri = URI->new('https://www.example.com/cgi-bin/login.cgi');
    $uri->query_form(name => $login, passwd => $password, submit => 1);
    
    $contents=get($uri);
    Last edited by schragge; April 6th, 2013 at 02:04 PM.

  7. #7
    Join Date
    Dec 2005
    Location
    Bourenmouth, Dorset
    Beans
    32
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Perl Mechanize programming

    Ok

    This is all unfamiliar to me.

    If thats the login done, I then want to loop x times for the following two pages.
    The next page has radio buttons to select, a text box to put a value into and a submit button to click.
    The following pagen then has a confirm button to submit.
    From before Ubuntu 10.10

  8. #8
    Join Date
    Dec 2005
    Location
    Bourenmouth, Dorset
    Beans
    32
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Perl Mechanize programming

    Hi

    Thanks for your input and programming tips.

    I found and worked out a solution using HTTP::Recorder.

    With Recorder you set your local pc as a proxy, navigate to your website of interest, do the tasks you want to repeat in a script, the results are saved. Then to make them a perl script add the Perl and Mechanize headers.

    Job done.

    Found it in a web testing article.
    http://www.perl.com/pub/2004/06/04/r...#control_panel
    From before Ubuntu 10.10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •