WWW:Mechanize problem?

WWW:Mechanize problem?

am 29.01.2007 13:00:37 von george veranis

I use this script :

ï»=BF#! /usr/bin/perl
use strict;
use WWW::Mechanize;
use HTTP::Cookies;
my $outfile =3D "out.txt";
my $url=3D"http://opac.uom.gr/ipac20/ipac.jsp?
profile=3Dbib-1--1&menu=3Daccount&ts=3D1163590369197";
my $username =3D $ARGV[0];
my $mech =3D WWW::Mechanize->new();
$mech->cookie_jar(HTTP::Cookies->new());
$mech->get($url);
$mech->form_name('security');
$mech->field(sec1 =3D> $username);
$mech->submit_form();

my $flag;
$flag =3D $mech->content() =3D~ /Borrower ID/;

open(OUTFILE, ">$outfile");

if ($flag){
print OUTFILE "Failure";
}
else{
print OUTFILE "Success";

}
#print OUTFILE "$flag";
close(OUTFILE);

and I get the following message if i write perl -w namefile.pl
outside

at /home/cpanrun/parisc2.0-lp64/build/5.8.2/lib/
site_perl/5.8.2/WWW/Mechanize.pm line 1825

but if I run the same script under Windows I get the right results.

On linux server i have perl 5.8.5 and localhost in windows i have perl=20
58.4

Have somebody any idea what is the problem because I search for i over=20
a week and I can't find a solution..

Thanks in advance for a reply..

Re: WWW:Mechanize problem?

am 29.01.2007 16:59:35 von Peter Scott

On Mon, 29 Jan 2007 04:00:37 -0800, george veranis wrote:
> use strict;
> use WWW::Mechanize;
> use HTTP::Cookies;
> my $outfile = "out.txt";
> my $url="http://opac.uom.gr/ipac20/ipac.jsp?
> profile=bib-1--1&menu=account&ts=1163590369197";
> my $username = $ARGV[0];
> my $mech = WWW::Mechanize->new();
> $mech->cookie_jar(HTTP::Cookies->new());
> $mech->get($url);
> $mech->form_name('security');
> $mech->field(sec1 => $username);
> $mech->submit_form();
>
> my $flag;
> $flag = $mech->content() =~ /Borrower ID/;
>
> open(OUTFILE, ">$outfile");
>
> if ($flag){
> print OUTFILE "Failure";
> }
> else{
> print OUTFILE "Success";
>
> }
> #print OUTFILE "$flag";
> close(OUTFILE);
>
> and I get the following message if i write perl -w namefile.pl
> outside at /home/cpanrun/parisc2.0-lp64/build/5.8.2/lib/
> site_perl/5.8.2/WWW/Mechanize.pm line 1825
>
> but if I run the same script under Windows I get the right results.

Firstly, that's just a warning, so the program should otherwise behave
identically on both machines.

Secondly, inspection of sources suggests that you have an older version of
HTML::Form on the first box, when it issued that message if warnings were
enabled. The current version requires a verbose flag to be set that
Mechanize does not enable. Or you're not using -w when you run the
program on the Windows box.

Thirdly, the message is alerting you to the fact that the HTML has
an tag (probably hidden) not between tags. HTML::Form
won't add them as inputs to a form. Perhaps some browsers have the
"helpful" behavior of adding them to any form submitted from that page; I
don't know, but it violates the HTML standard. If the form action target
requires those inputs to be set you'll have to add them manually.

--
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/