|
Posted by fdl on December 15, 2004, 5:39 pm
Please log in for more thread options
Hello,
I'm trying to execute the following (still incomplete) script:
use strict;
use Win32::IE::Mechanize;
my $ie = Win32::IE::Mechanize->new(visible=>1);
$ie->get("something was here but is removed for security reasons");
sleep 1;
my $webpagetext = "nothing yet";
$webpagetext = $ie->content(format=>"text");
my @webforms = $ie->forms;
my $webformstotal = @webforms;
print "number of forms found = $webformstotaln";
print "webform : $webforms[0]n";
my $loginform = $ie->current_form;
print "loginform : $loginformn";
$loginform->field("user",'some user was here');
$loginform->field("password",'some password was here');
but I'm getting the error code :
"Can't locate object method "field" via package "Win32::IE::Form" at
testweb.pl"
Does anyone have any idea what this beginner is doing (stupidly)
wrong?
Thanks in advance,
Filip
--
fdl
|
|
Posted by JayEs on December 29, 2004, 5:50 pm
Please log in for more thread options
<SNIP>
> sleep 1;
Nothing to do with your question, but the sleep is not needed. IE::Mecahnize
waits until all requests are completed anyway (at least that is my
experience).
> my $webpagetext = "nothing yet";
Again, not relevant to the question, but this can be rewritten as:
my $webpagetext;
No need to assign anything, or faster yet:
my $webpagetext = $ie->content(format=>"text");
> my $loginform = $ie->current_form;
> print "loginform : $loginformn";
>
> $loginform->field("user",'some user was here');
current_form is a "status" method. It returns the current form, but I don't
think it actually does anything with it. I have only limited experience with
IE::Mech, but I think what is going wrong is that you are not telling the
script which form on the page to use, or not correctly anyway. Instead I
think you should use: form_name (or if the form doesn't have a name:
form_number).
What has always worked for me is:
(some code omitted)
my $ie = Win32::IE::Mechanize->new( visible => 1);
$ie->get($url);
$ie->form_name("some name here");
$ie->field("some field", 'some value');
Also you probably don't need all the extra variables if all you are doing is
trying to fill out a simple login form. You can get rid of $loginform,
@webforms and $webformstotal
Try that and see if it helps you out any....
JS
|
| Similar Threads | Posted | | win32::ie::mechanize PROBLEM | December 10, 2004, 7:06 am |
| RFC: field::aliases | September 26, 2004, 5:01 am |
| Entering pathnames in a CGI.pm field | January 28, 2005, 12:30 am |
| NetPacket::TCP and "options" field | February 15, 2005, 1:18 pm |
| DBI problem -- storing large value into an INT8 field | January 4, 2007, 10:28 am |
| Help with Mechanize | January 15, 2007, 3:14 pm |
| WWW::Mechanize v 1.03_01 | August 3, 2004, 9:57 pm |
| Mechanize question | November 8, 2004, 10:57 pm |
| WWW:Mechanize with Menu | September 9, 2006, 9:13 pm |
| WWW:Mechanize problem? | January 29, 2007, 7:00 am |
|