note
Limbic~Region
[OfficeLinebacker],
<br />
Have you seen [mod://WWW::Mechanize::Sleepy]? Personally, I use something along the lines of:
<CODE>
# Sleep a random interval between $duration and 2 * $duration - 1 unit
sub rest {
my ($duration) = @_;
sleep $duration;
sleep rand($duration);
}
sub fetch_page {
my ($mech, $action, $target, $max, $duration) = @_;
for (1 .. $max) {
rest($duration);
eval {$mech->$action($target);};
return if ! $@ && $mech->status == OK;
}
die "Failed to fetch '$url' after '$max' attempts\n";
}
</CODE>
<p>
Of course, if you want to allow for HTTP redirects then you will need to change status == OK to include acceptable HTTP codes. Additionally, if you use [mod://Time::HiRes] to overload [doc://sleep], you can easily sleep for partial minutes. In truth, I typically use milliseconds.
</p>
<div class="pmsig"><div class="pmsig-180961">
<p>
Cheers - [Limbic~Region|L~R]
</p>
</div></div>
929348
929634