使用php curl进行视频下载

时间:2016-03-22 21:37:34

标签: php curl

我必须用curl下载大型视频。因为我下载的网站放了403块,而我只能通过Curl传递。多数民众赞成我的php curl功能代码。我需要下载它,但它不应该吃掉我的记忆..

function fakeip()
{
//return long2ip( mt_rand(0, 65537) * mt_rand(0, 65535) ); 
return "127.0.0.1";
}
    function curlx($feed,$coo=null,$ref=null)
{

        $ch = curl_init();
        $timeout = 0;
        curl_setopt ($ch, CURLOPT_URL, $feed);
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("REMOTE_ADDR: ".fakeip(),"X-Client-IP: ".fakeip(),"Client-IP: ".fakeip(),"HTTP_X_FORWARDED_FOR: ".fakeip(),"X-Forwarded-For: ".fakeip()));
        curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0');
        //curl_setopt($ch, CURLOPT_INTERFACE, "88.150.225.55");
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_FAILONERROR, true); 
        if(!empty($coo))
        {
            curl_setopt($ch, CURLOPT_COOKIEFILE, $coo);
            curl_setopt($ch, CURLOPT_COOKIEJAR, $coo);
        }
        if(empty($ref))
        {
            curl_setopt($ch, CURLOPT_REFERER,$feed);
        }
        else
        {
            curl_setopt($ch, CURLOPT_REFERER,$ref);
        }
        curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        $veri= curl_exec($ch);
        curl_close($ch);
         return str_replace(array("\n", "\t", "\r",), null, $veri); 
}

0 个答案:

没有答案