#!/usr/bin/perl --
use strict;
use warnings;
use WWW::Mechanize 1.66;
use URI::file;
Main( @ARGV );
exit( 0 );
sub Main {
my $ua = WWW::Mechanize->new( autocheck => 1, );
$ua->timeout(0.00000000001);
$ua->get( URI::file->new(__FILE__)->abs( URI::file->cwd ) );
$ua->update_html( <<'HTML' );
<html> <head>
<title> test.html : localhost form </title>
</head> <body>
<base href="http://localhost/">
<form method="POST" action="http://localhost/">
<input type="hidden" name=r0 value=0 disabled>zero
<input type=radio name=r1 value=1 disabled>one
<input type=radio name=r1 value=2>two
<input type=radio name=r1 value=3>three
<input type=radio name=r2 value=1>one
<input type=radio name=r2 value=2 disabled>two
<input type=radio name=r2 value=3>three
<input type="submit">
</form>
</body> </html>
HTML
print $ua->dump_forms,"\n\n";
$ua->set_fields( qw' r1 three r2 three r3 three ');
print $ua->dump_forms,"\n\n";
$ua->set_fields( qw' r2 7 ');
print $ua->dump_forms,"\n\n";
$ua->add_header( Referer => undef );
$ua->add_handler(
"request_send",
sub { $_[0]->dump; return; },
m_method => 'POST'
);
$ua->submit(0);
$ua->delete_header( 'Referer' );
}
__END__
$ perl mechanize.radio.pl
POST http://localhost/
r0=0 (hidden disabled readonly)
r1=<UNDEF> (radio) [-1/one|2/two|3/three]
r2=<UNDEF> (radio) [1/one|-2/two|3/three]
<NONAME>=<UNDEF> (submit)
POST http://localhost/
r0=0 (hidden disabled readonly)
r1=3 (radio) [-1/one|2/two|*3/three]
r2=3 (radio) [1/one|-2/two|*3/three]
<NONAME>=<UNDEF> (submit)
r3=three (text)
POST http://localhost/
r0=0 (hidden disabled readonly)
r1=3 (radio) [-1/one|2/two|*3/three]
r2=7 (radio) [1/one|-2/two|:3/three]
<NONAME>=<UNDEF> (submit)
r3=three (text)
POST http://localhost/
Accept-Encoding: gzip
User-Agent: WWW-Mechanize/1.66
Content-Length: 18
Content-Type: application/x-www-form-urlencoded
r1=3&r2=7&r3=three
Error POSTing http://localhost/: Can't connect to localhost:80 (timeou
+t) at mechanize.radio.pl line 63
|