public static function fetchContent($url, $verbose = false) { $match_part = parse_url((substr($url, 0, 4) != 'http' ? 'http://' : '') . $url); self::$host = $match_part["scheme"] . "://" . $match_part["host"]; if (($curl = curl_init($url)) == false) { throw new Exception("curl_init error for url {$url}."); } if (self::$proxyCount > 0) { $proxy = self::$proxyServers[self::$currentProxyIndex++ % self::$proxyCount]; curl_setopt($curl, CURLOPT_PROXY, $proxy); if ($verbose === true) { echo "Reading {$url} [Proxy: {$proxy}] ... "; } } else { if ($verbose === true) { echo "Reading {$url} ... "; } } curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt_array($curl, self::$options); $content = curl_exec($curl); if ($content === false) { throw new Exception("curl_exec error for url {$url}."); } curl_close($curl); if ($verbose === true) { echo "Done.\n"; } return $content; }