Hello All,

I have been having trouble figuring out Mechanize module specially on
getting back the results after submitting a form. I am trying to
access ancestry dot com to get the results according to the the form
that I submit. Fallowing code is written to fill the First Name input
field and Last Name Input Filed and submit.

I went through great trouble figuring out some section since ancestry
dot com site doesn't name their input fields. But according to the
below code segment I only get spitted out html version of the first
page of the ancestry dot com whereas I would like to see the results
according to the first and last name that I submit.

Currently I am just trying to figure out on getting the results back.
Once I get pass this, I will be using some of the functions that I
have created to fill the first and the last name instead of passing
the plain first and last name.

#!/usr/bin/perl

use Text::Soundex;
use WWW::Mechanize;
#use MakeRegex;
$DEBUG = true;
$SOUNDEX = 0;

print STDOUT "\nEnter First name: ";
$firstname = <STDIN>;
chomp $firstname;

print STDOUT "\nEnter Last name: ";
$lastname = <STDIN>;
chomp $lastname;

my $url = 'http://www.ancestry.com/';
my $mechObject = WWW::Mechanize->new();

$mechObject->get($url);
die "can't get page!"
  unless $mechObject->success &&
                $mechObject->content =~ /Your First Name/i;

die "can't find form!"
  unless $mechObject->form_number(2);

my @values = ($firstname, $lastname, [option => 'M']);
die "couldn't fill out form!"
  unless $mechObject->set_visible(@values) == 3;

$mechObject->submit;
die "can't submit form!"
  unless $mechObject->success &&
                $mechObject->content =~ /Your Last Name/i;

It will be a great help if someone could give some audience on this.

Thanks, Anu


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to