my $cookie_jar = new HTTP::Cookies(file => "cookies.txt");
$cookie_jar->load; END { $cookie_jar->save };
my $mech = new WWW::Mechanize( user_agent => "mp3slurpy/1.0", cookie_j
+ar => $cookie_jar );
$mech->get( $login_page );
$mech->submit_form(
form_number => 3,
fields => {
username => 'mungo',
password => 'lost-and-alone',
}
);
$mech->get( $mp3_file, ":content_file" => $output_file );
PS, there's no real reason to choose WWW::Mechanize over LWP::UserAgent except for the ease of using the API... Mech uses LWP though, so there's no disadvantage for picking it either.
|