how to automate webpage interaction?

W

walala

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
 
J

John J. Lee

walala said:
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
 
G

Glenn Jackman

walala said:
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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top