Click here to get back home

WWW:Mechanize problem?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
WWW:Mechanize problem? george veranis 01-29-2007
Get Chitika Premium
Posted by george veranis on January 29, 2007, 7:00 am
Please log in for more thread options


I use this script :

=EF=BB=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
<input> outside <form> 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
5=2E8.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..


Posted by Peter Scott on January 29, 2007, 10:59 am
Please log in for more thread options


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
> <input> outside <form> 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 <INPUT> tag (probably hidden) not between <FORM> 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/


Similar ThreadsPosted
win32::ie::mechanize PROBLEM December 10, 2004, 7:06 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 "There is no Form named (...)" December 8, 2004, 5:58 am
WWW::Mechanize and NTLM authentication December 21, 2004, 3:55 pm
www::mechanize $mech->select February 4, 2005, 5:01 pm
WWW::Mechanize cannot find the form. February 14, 2006, 9:04 pm
WWW::Mechanize single quotes around url January 12, 2007, 12:54 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap