|
Wednesday, 23 September 2009 21:40 |
#!/usr/bin/perl use LWP::UserAgent; use HTTP::Request::Common qw(GET); use URI;
use constant MAINPAGE => 'http://www.example.com/search.asp';
$UA = LWP::UserAgent->new(); $req = HTTP::Request->new( GET => MAINPAGE );
# This array says test 8-bits, 16-bits, and 32-bits my @testSizes = ( 8, 16, 32 );
foreach $numBits (@testSizes) { my @boundaryValues = ( ( 2**( $numBits - 1 ) - 1 ), ( 2**( $numBits - 1 ) ), ( 2**( $numBits - 1 ) + 1 ), ( 2**$numBits - 1 ), ( 2**$numBits ), ( 2**$numBits + 1 ), ); foreach $testValue (@boundaryValues) { my $url = URI->new(MAINPAGE); $url->query_form( 'term' => 'Mac', 'max' => $testValue );
# do the fetching of pages inside a loop, where we change the # parameter we're tinkering with each time. $req->uri($url); $resp = $UA->request($req);
# Report any errors if ( ( $resp->code() < 200 ) || ( $resp->code() >= 400 ) ) { print resp->status_line . $req=>as_string(); } } }
|