<?php
$html = file_get_contents("https://site.com");
preg_match_all('#href="(.*?)"#si',$html,$hrefs);
$hrefs = $hrefs[0];
$total  = count($href);

$href = $hrefs[0,rand(0,$total)-1];