<form method="post" action="http://..."> <div class="ABC"> <div class="DEF"><input type="radio" name="Radio" id="1" value="1" />< +label for="1">Option1</label></div> <div class="DEF"><input type="radio" name="Radio" id="2" value="2" />< +label for="2">Option2</label></div> <div class="DEF"><input type="radio" name="Radio" id="3" value="3" />< +label for="3">Option3</label></div> </div> <div class="buttons"> <div class="spacer"></div> <input type="submit" class="form_buttons" name="submit" value="Submit +Form" /> <div class="form_buttons"><a href="http://..." title="...">...</a></di +v> <input type="hidden" name="ID" value="Form_ID" /> <div class="spacer"></div> </div> </form>
#!/usr/bin/perl -w use strict; use WWW::Mechanize; use Crypt::SSLeay; use HTTP::Cookies; my $agent = WWW::Mechanize->new(); my $cookie_file = "Cookies.txt"; $agent -> cookie_jar( HTTP::Cookies->new( File => $cookie_file, autosa +ve => 1 )); my $page = 'http://...'; # Request the page. $agent -> get( $page ); # Set the radiobutton 'Radio' to the second option. $agent -> set_fields( 'Radio' => '2' ); # Now post the poll form to the URL given in the source code under act +ion="http://...". $agent -> post( 'http://...' );
In reply to Problem submitting form with Mechanize by pat_mc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |