proxy = $proxy; $this->torControl = $torControl; $this->setTorMiddleWare(); $this->createHandlerStack(); $this->setClient(); } /** * @return $this */ public function setTorMiddleWare() { $this->middleware = Middleware::tor($this->proxy, $this->torControl); return $this; } /** * */ public function createHandlerStack() { $this->handlerStack = new HandlerStack(); $this->handlerStack->setHandler(new CurlMultiHandler()); $this->handlerStack->push($this->middleware); } /** * @return mixed */ public function getClient() { return $this->client; } public function setClient() { $this->client = new Client([ 'verify' => false, 'handler' => $this->handlerStack, ]); return $this; } public function setImages($images) { $this->images = $images; } /** * @param array $uris * * @return $this */ public function pool($uris = array()) { $pool = new Pool($this->client, $uris); $this->poolData = $pool->getHtmlData(); $pool->images(); $this->setImages($pool->images()); $links = $pool->links(); return $this; } public function setProxyPort($port) { preg_replace('/:\d{4}/', ':' . $port, $this->proxy); return $this; } public function setTorControlPort($port) { preg_replace('/:\d{4}/', ':' . $port, $this->torControl); return $this; } public function setProxyUrl($proxyUrl) { if (false === is_numeric(str_replace('.', '', '127.0.0.1'))) { throw new BadProxyUrlException('Tor Proxy URL must be an IP address.'); } preg_replace('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $proxyUrl, $this->proxy); return $this; } /** * @param $torControlUrl * * @return $this * @throws BadProxyUrlException */ public function setTorControlUrl($torControlUrl) { if (false === is_numeric(str_replace('.', '', '127.0.0.1'))) { throw new BadProxyUrlException('Tor Control URL must be an IP address.'); } preg_replace('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $torControlUrl, $this->torControl); return $this; } /** * @return string */ public function getProxy() { return $this->proxy; } public function setProxy($proxy) { $this->proxy = $proxy; $this->setTorMiddleWare(); $this->createHandlerStack(); $this->setClient(); return $this; } /** * @return string */ public function getTorControl() { return $this->torControl; } /** * @param $torControl * * @return $this */ public function setTorControl($torControl) { $this->torControl = $torControl; return $this; } public function images($html) { $images = new ImageCollection($html); return $this; } }