how to automate webpage interaction?

Discussion in 'Perl Misc' started by walala, Nov 2, 2003.

  1. walala

    walala Guest

    Dear all,

    I try to use Perl to automating the log-on process to 'mail.yahoo.com'
    webpage. Here is my program:

    ---------------------------------------------------
    use Clone;
    use WWW::Automate;
    my $agent = WWW::Automate->new();
    $url='mail.yahoo.com';
    $agent->get($url);

    #$agent->follow($link);

    $agent->form(2);
    $agent->field($name, $value);
    $agent->click($button);

    $agent->back();

    $agent->add_header($name => $value);

    print "OK" if $agent->{content} =~ /$expected/;

    -----------------------------------------------------------

    However, it gives error message that "there is no form number 2"...

    Can anybody tell me what is the form number of that "login" and "passwd"
    field in "mail.yahoo.com"?

    And how to find it out?

    Thanks a lot,

    -Walala
    walala, Nov 2, 2003
    #1
    1. Advertising

  2. walala

    John J. Lee Guest

    "walala" <> writes:
    > I try to use Perl to automating the log-on process to 'mail.yahoo.com'
    > webpage. Here is my program:

    [...]
    > However, it gives error message that "there is no form number 2"...
    >
    > Can anybody tell me what is the form number of that "login" and "passwd"
    > field in "mail.yahoo.com"?


    Everybody and their dog has written a script to fetch mail from
    mail.yahoo.com. If this isn't just a little problem you've set
    yourself, use one of those instead.

    > And how to find it out?


    I guess form(2) is the second form on the page (assuming this module
    uses HTML::Form, it'll count from 1, not 0). So look in the HTML for
    your <FORM>...</FORM>, and count how many forms there are in the page
    before that. Add one. That's your form number.


    John
    John J. Lee, Nov 2, 2003
    #2
    1. Advertising

  3. walala <> wrote:
    > use WWW::Automate;
    > my $agent = WWW::Automate->new();
    > $url='mail.yahoo.com';
    > $agent->get($url);
    > $agent->form(2);

    [...]
    > However, it gives error message that "there is no form number 2"...


    Have you read the WWW::Automate documentation?
    Have you read the source for mail.yahoo.com? How many forms are there?

    --
    Glenn Jackman
    NCF Sysadmin
    Glenn Jackman, Nov 2, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    401
  2. DarkBlue

    Automate webpage refresh

    DarkBlue, Dec 1, 2005, in forum: Python
    Replies:
    4
    Views:
    338
    DarkBlue
    Dec 5, 2005
  3. Paul
    Replies:
    14
    Views:
    825
    Alexey Smirnov
    Jun 19, 2008
  4. sifar
    Replies:
    5
    Views:
    387
  5. Ted Byers
    Replies:
    1
    Views:
    135
    Thomas 'PointedEars' Lahn
    Aug 13, 2009
Loading...

Share This Page