Home>
I am currently writing the following crawling code using curl.

Time of 30 seconds exceeded due to network conditions.

PHP processing timeout measures
Is there a better way besides changing the timeout time?

public function downloadAllFile ($interval = 2)
{
    foreach ($this->tests as $test) {
        $data = $this->downloadFile ($test);
        $this->saveFile ($data, $test);
        sleep ($interval);
    }
}
public function downloadFile ($test)
{
    $url = $this->url. $test;
    $ch = curl_init ($url);
    curl_setopt ($ch, CURLOPT_HTTPHEADER, $this->headers);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt ($ch, CURLOPT_COOKIEFILE, dirname (__ FILE__). "/tmp/cookie.txt");
    $data = curl_exec ($ch);
    curl_close ($ch);
    return $data;
}
php