Here's a function that uses Snoopy to return the nth (array[n]) link from a page:
function nth_link($uri, $n)
{
include_once 'Snoopy.class.php';
$snoopy = new Snoopy;
if($snoopy->fetchlinks($uri)) {
$arr = $snoopy->results;
if (isset($arr[$n])) {
return $arr[$n];
} else {
return false;
}
} else {
return false;
}
}