http://www.perlmonks.org?node_id=600562

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

Due to a very obstinate website, I'm having problems obtaining all of the inputs for a particular web form using WWW::Mechanize. My $mech object only returns two of the inputs whereas there should be 4 returned. You can see all the possible inputs in the source (the form name is "aspnetForm"). Since the other two aren't returning, I'd like to add those missing values to the HTML::Form object and submit them. It doesn't look like the HTML::Form object allows this; it will allow you to modify existing inputs but not add entirely new ones that weren't in the retrieved form.

Here is the link: http://friends.myspace.com/index.cfm?fuseaction=user.viewfriends&friendID=29006405

1) Is there a way to add an input to an HTML::Form object?
2) If not, is there a way to create an HTML::Form object from scratch?

Replies are listed 'Best First'.
Re: HTML::Form - Can you add new inputs?
by initself (Monk) on Feb 17, 2007 at 01:40 UTC
    Solved it. There is an internal method to HTML::Form called push_input. I just had to use it. It should probably be in the docs for HTML::Form, eh?
    my @attr = ( { 'name' => '__EVENTTARGET', 'id' => '__EVENTTARGET', 'value' => 'ctl00$cpMain$pagerTop', }, { 'name' => '__EVENTARGUMENT', 'id' => '__EVENTARGUMENT', 'value' => '2', }, ); for (@attr) { $mech->form_number(0)->push_input('hidden', $_); }
Re: HTML::Form - Can you add new inputs?
by AK108 (Friar) on Feb 17, 2007 at 17:58 UTC

      This is precisely the kind of useful help from other monks that prompted me to write "Perl Monks += TMTOWTDI"..

Re: HTML::Form - Can you add new inputs?
by EvanCarroll (Chaplain) on Aug 21, 2008 at 20:33 UTC