in reply to Re^2: Headers and WWW::Mechanize
in thread Headers and WWW::Mechanize

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();

Replies are listed 'Best First'.
Re^4: Headers and WWW::Mechanize
by Anonymous Monk on Jan 31, 2007 at 01:03 UTC
    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;

      This error comes because WWW::Mechanize does not find a field by that name in the current form. Maybe such a field does not exist.

      Inspect your current HTML and your current form and look if they are what you think they are. Convenient methods for inspecting are:

      print $mech->content; $mech->save_content('progress.html');
      .

      Also, the documentation recommends the mech-dump utility for inspecting a page and its forms and fields.

      Have you looked at WWW::Myspace ?