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

Trying to get a form filler to work for http://www.letssingit.com/ (the top search bar).

I don't know what I am doing wrong but this code is bringing back the errror of Can't call method "value" on an undefined value at /home/sash/public_html/lib//WWW/Mechanize.pm line 1154. Can someone help me get this to work to automate this form?

my $url = "http://www.letssingit.com"; use lib "/home/sash/public_html/lib/"; use WWW::Mechanize; my $mech = WWW::Mechanize->new(agent=>"wonderbot" ); $mech->get($url); print header, start_html("lyrics grabber"); $mech->submit_form( form_name => "search", fields => { query => 'search', }, button => 'Go' ); $mech->uri();

Replies are listed 'Best First'.
Re: Getting a form filler to work for letssingit.com
by sh1tn (Priest) on Apr 12, 2005 at 23:06 UTC
    More important - the error says:
    "There is no form named "search""
    You can check forms' names with:
    >mech-dump http://www.letssingit.com >mech-dump http://www.letssingit.com/frame_menu.html GET http://www.letssingit.com/frame_menu.html [theClock] theTime= POST http://www.letssingit.com/cgi-exe/am.cgi [search] s= l=artist (option) [*artist/artistname|album/albumname|song/songname|lyrics|fanpage] <NONAME>=GO (submit) a=search (hidden) p=1 (hidden)


      Which means you (the OP) should be using:
      ... my $url = "http://www.letssingit.com/frame_menu.html"; my $query = ...; ... $mech->submit_form( form_name => 'search', fields => { s => $query, l => 'song', # or 'artist' or 'album' or 'lyrics'. # The only button doesn't have a name, so no # need to put anything here for the button. }, ); ...
        Hi. Thanks for the updated code I have one last question.

        I need to know what's on the page now so I'm trying to do a page dump using $mech->uri() but it's printing out a URL instead of the HTML and all that. What do I use to get the page to load?