PHP中的cURL在IP更改后停止工作

PHP中的cURL在IP更改后停止工作,php,curl,libcurl,Php,Curl,Libcurl,我有一个PHP脚本,可以通过cURL在URL下载所有内容: <?php function get_curl_output($link) { $channel = curl_init(); curl_setopt($channel, CURLOPT_URL, $link); curl_setopt($channel, CURLOPT_HEADER, 0); curl_setopt($channel, CURLOPT_RETURNTRANSFER, 1);

我有一个PHP脚本,可以通过cURL在URL下载所有内容:

 <?php
 function get_curl_output($link)
{
    $channel = curl_init();
    curl_setopt($channel, CURLOPT_URL, $link);
    curl_setopt($channel, CURLOPT_HEADER, 0);
    curl_setopt($channel, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($channel, CURLOPT_CONNECTTIMEOUT, 10000);
    curl_setopt($channel, CURLOPT_TIMEOUT, 10000);
    curl_setopt($channel, CURLOPT_VERBOSE, true);
    curl_setopt($channel, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219');
    curl_setopt($channel, CURLOPT_FOLLOWLOCATION, true);
    $output = curl_exec($channel);
    if(curl_errno($channel))
    {
        file_put_contents('curlerror.txt', curl_error($channel) . PHP_EOL, FILE_APPEND);
    }
    curl_close($channel);
    return $output;
 ?>

 <?php
 function downloader($given_url){
     //download all the url's content in the $given_url.
     //if this $given_url is an array with 10 urls inside it, download all of their content. 
      while(as long as i find a url inside $given_url){
            $content_stored_here = get_curl_output($link);
            //and put that content to a file
      }
}
?>


你不需要这么大的暂停时间;当没有连接时,cUrl会根据您的代码尝试连接长达10000秒。将其设置为更合理的值-例如,仅为10,如果您声称的代码是一个只包含注释的空函数,则不会得到太多帮助。你能提供一些实际的代码给我们看吗?你是如何启动你的php脚本的?是不是有工作?cronjob是在CLI中运行php还是在wget php文件?所以我在问是否涉及Apache…是的,它涉及Apache还是我应该使用CGI?@cincodenada我添加了源代码。你理解这里的要点!!连接丢失后,它将无法工作。脚本将停止。。