in reply to Headers and WWW::Mechanize

As these fields are already hidden fields in your current form, all you need to do is to set them to the values you want and then submit that form. What is your code? Most likely $ie->form->submit should Just Work.

Replies are listed 'Best First'.
Re^2: Headers and WWW::Mechanize
by Anonymous Monk on Jan 30, 2007 at 01:54 UTC
    Here is my code I'm testing with, but it complains that fields_ref is unknown and using fields results in another error. I'm lost...
    use warnings; use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $id = '14632'; my $url = "http://home.myspace.com/index.cfm?". "fuseaction=user.viewfriends&". "friendID=" . $id; $mech->get( $url ); my ($viewstate) = $mech->content =~ m/name="__VIEWSTATE".+value="([^"] ++)"/io; # print "VIEWSTATE: $viewstate\n"; # Submit an dmove to page 2 $mech->submit_form( #page => $url, form_name => 'aspnetForm', fields_ref => { '__EVENTTARGET' => 'ctl00$cpMain$pagerTop' +, '__EVENTARGUMENT' => 2, '__VIEWSTATE' => $viewstate, } ); #print $mech->content;
    Any idea what I'm doing wrong?

      As long as you don't tell us what that "other error" with using ->fields is, we can't help you. The WWW::Mechanize documentation says to use fields:

      $mech->submit_form( form_number => 3, fields => { username => 'mungo', password => 'lost-and-alone', } );

      Personally, I would set the fields in the HTML form and then simply submit the form:

      my $form = $mech->form_name('aspnetForm'); $form->value('__EVENTTARGET' => 'ctl00$cpMain$pagerTop'); ... and so on $mech->submit();
        The other error I get is: No such field '__EVENTTARGET' at test.pl line 17...
        use warnings; use strict; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $id = '14632'; my $url = "http://home.myspace.com/index.cfm?". "fuseaction=user.viewfriends&". "friendID=" . $id; $mech->get( $url ); my $form = $mech->form_name('aspnetForm'); $form->value('__EVENTTARGET' => 'ctl00$cpMain$pagerTop'); $form->value('__EVENTARGUMENT' => 2); $mech->submit(); print $mech->content;
A reply falls below the community's threshold of quality. You may see it by logging in.