Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

WWW::Mechanize Unknown input type 'search'

by zer (Deacon)
on Nov 08, 2007 at 04:31 UTC ( #649650=perlquestion: print w/replies, xml ) Need Help??

zer has asked for the wisdom of the Perl Monks concerning the following question:

Good Evening,
The code i wrote here isn't the best. Please bear with me.

When it executes it spews out a bunch of mechanize warnings which i am not sure what it means. Execution is by command line whateverpassword

This looks at a certain website and grabs all your friends and messages a happy b-day greeting if their b-day is today.

#!/usr/bin/perl -w use strict; my $MONTH=qr/(January|February|March|April|May|June|July|August|Septem +ber|October|November|December)(?=[^a-zA-Z])/; my @abbr = qw(January February March April May June July August Septem +ber October November December); use WWW::Mechanize; my $url = ""; my $m = WWW::Mechanize->new(); $m->get($url); $m->submit_form(form_name=>"loginform", fields=>{email=>$ARGV[0], pass +=>$ARGV[1]}); $m->get("/bdaycal.php"); my $b= $m->content(); $b=~/.... Birthdays(.*?)Facebook /g; $b=$1; $b=~s|(http://\w+\\.php\?id=\d+)| > $1_<|g; $b=~s/<[^>]*>//g; $b=~s/Give a Birthday Gift \| Post a Birthday Flyer//g; $b=~s/&nbsp;//g; my @C = split /$MONTH/,$b; shift @C; my %B=@C; my $count=0; my %O; for (keys %B){ while ($B{$_}=~s/^(\d\d)-(.*?)(\d\d-.*)$/$3/){ my $day = $1*1; my @T=split ",",$2; my @S; foreach my $t(0..$#T){ my ($id,$age,$name); $id=($T[$t]=~s/([^_]+)_//)?$1:""; $age=($T[$t]=~s/\(age (\d\d)\)//)?$1:""; $name=$T[$t]; $O{$_}->{$day}->[$t]= {id=>$id, age=>$age, name=>$name }; $count++; } } }; my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time +); $mon=$abbr[$mon]; for (@{$O{$mon}->{$mday}}){ $m->get($_->{id}); print $_->{name}; my $Form=0; for ($m->forms){ $Form++; last if $_->find_input ("wall_text"); } print ((($m->submit_form(form_number=>$Form, fields=>{wall_text=>" +Happy Birthday!"}))?" - Success":" - Failed"),"\n"); }

The Errors that it produces:

Unknown input type 'search' at /usr/local/share/perl/5.8.8/WWW/Mechani line 2055 Use of uninitialized value in substitution iterator at /usr/share/perl +5/URI/ line 16. Unknown input type 'search' at /usr/local/share/perl/5.8.8/WWW/Mechani line 2055 Unknown input type 'search' at /usr/local/share/perl/5.8.8/WWW/Mechani line 2055 Unknown input type 'search' at /usr/local/share/perl/5.8.8/WWW/Mechani line 2055

The warnings seem to come only after get() requests. Any guidance would help. As well this is WWW::Mechanize ver 1.32. This is also likely something that I should have noticed.

Replies are listed 'Best First'.
Re: WWW::Mechanize Unknown input type 'search'
by zer (Deacon) on Nov 08, 2007 at 05:18 UTC
    Thanks to tye getting me in the right direction. The page being called had a:
    <input id="q" class="search inputsearch inputtext" name="q" type="sear +ch" ...

    This caused the HTML::Form module to have problems as "The following type names are used: "text", "password", "hidden", "textarea", "file", "image", "submit", "radio", "checkbox" and "option"." Which is the xhtml standard.

    With a deeper look this doesn't appear to be a problem with HTML::Form though. Probably something syntactic with undefined values in my own code.

      type="search" is not an HTML standard. It seems to be some sort of custom WebKit property. I've spoken to Andy Lester, the writer of WWW::Mech, and he said the only way to prevent warnings is to actually disable them with local $^W=0 or a more flexible reassigning of $SIG{__WARN__} to filter your warnings.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://649650]
Approved by tye
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2022-08-14 09:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found