Introduction to writing spiders and agents
Fault Tolerance: Look for redirects in headers
       
    function get_first_page($URL)
        {
        $header = `c:\curl\curl --head $URL`;
        $parsed = inclusive_parse(
                $string=$header,
                $start="Location: ",
                $end="\n",
                $max_span=50
                );
        return $parsed[0];
      }