public function getUrl($url, $timeout = 5) { $this->initInstance(); curl_setopt($this->ch, CURLOPT_URL, $url); curl_setopt($this->ch, CURLOPT_TIMEOUT, intval($timeout)); if ($this->cookie) { curl_setopt($this->ch, CURLOPT_COOKIE, $this->cookie); } if (is_array($this->use_proxy)) { $retry = $this->use_proxy ? 1 : 3; for ($i = 0; $i < $retry; $i++) { $proxy = $this->use_proxy ?: Proxy::rand(); //允许手动指定Proxy配置 curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $proxy['delay']); curl_setopt($this->ch, CURLOPT_PROXY, $proxy['host']); curl_setopt($this->ch, CURLOPT_PROXYTYPE, $proxy['type']); $result = curl_exec($this->ch); if ($result && !curl_errno($this->ch)) { break; } } } else { $result = curl_exec($this->ch); } return curl_errno($this->ch) ? false : $result; }