in reply to Re: Re: Getting result page using WWW::Mechanize
in thread Getting result page using WWW::Mechanize

If you have to navigate a page containing frames, you have to navigate first to the frame page, and then use

$agent->follow();

to get to the page linked from that frame.

To set the value of a text field, use $agent->field("fieldname",$value);. To submit a form with a single button, you can either use $agent->submit() or $agent->click("button_name")

BTW, take a look at the Writeup Formatting Tips to see how to format code and your text.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Replies are listed 'Best First'.
Re: Re: Re: Re: Getting result page using WWW::Mechanize
by Anonymous Monk on Jul 04, 2003 at 11:03 UTC
    Hi Corion, Thank you for helping me to write the basic steps to implement the module. Still i didn't get any idea if i go for second level of form (First level is to get the inputs and submit and it will display a page. The second level is, in the display page if i have a text field say "age" and two buttons "continue" and "stop". I would like to input in the text field and click on the continue button . How can i add these steps in my previous code? It will be very useful for me, if you post that part. Thanks a lot.

      As long as you don't post the URL of the site you are trying to automate, I can only poke around in the dark - an exercise not very rewarding. I suggest that you install my module WWW::Mechanize::Shell, which allows you to explore a website interactively and afterwards spit out a complete Perl script that recreates what you did manually.

      My guess is, that the following commands in WWW::Mechanize::Shell should be sufficient in getting you to your goal :

      get http://www.example.com/ value login "username" value password "secret" click "Login" # You get a page back which is a frame page links # look at the links open "/data_frame/" value age 99 click "continue" content

      If you absolutely do not get WWW::Mechanize::Shell to install, I will try to translate that script into Perl manually, but please try ::Shell first, as it can display the current page in your browser for easy review.

      perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

        Hi Corion,

        Once again thanks for your explanation.

        I had modified my previous code like this to get the second level of the page... It's working fine.

        $first = $agent->submit(); $agent->get($first); print $agent->content;

        Before i did was a test program to use this module.

        I would like to connect a mail service to get a page from there.. this is i am trying now.

        URL of the site you are trying to automate is http://www.attachmail.com/

        • UserId is test01
        • Passwd is s
        • Click on Go image (name=imageField). It will display a useraccount page.
        • Click on the Addressbook button from the page. It will display Address book page contains 4 buttons (Add,Delete,Edit,close).
        • Click on Add button, it will display a page contains two text fields name and email address , Add and Close button.
        • Click on the Add button will display a page. This page i required.

        How can i do that?

        Hope you can help me to solve this problem. Thanks a lot and waiting for your great help.

        Regards,
        ps

        20030705 Edit by Corion: Added formatting