setCapability('timeout', 3600); $caps->setCapability(FirefoxDriver::PROFILE, $profile); $torProcess = TorLauncher::launch($firefoxBinary); // Wait for Tor to connect $sleepTime = 5; $torProcess->wait(function() use ($sleepTime) { sleep($sleepTime); }); $webDriver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $caps); $webDriver->manage()->timeouts()->implicitlyWait(5); $webDriver->navigate()->to('http://32b5oz2bbtn6gqj3.onion'); // Or $this-webDriver->get('http://32b5oz2bbtn6gqj3.onion'); $pageImages = $webDriver->findElements(WebDriverBy::tagName('img')); $images = []; $downloader = new ImageDownloader(); foreach($pageImages as $image) { $downloader->open($image->getAttribute('src')); print 'Saving image ' . $downloader->getFileName(); // write some data about the request file_put_contents( sys_get_temp_dir() . '/' . $downloader->getFileName() . '.meta.json', json_encode([ 'pathinfo' => $downloader->getPathInfo(), 'curlinfo' => $downloader->getCurlInfo(), 'webdriver' => [ 'title' => $webDriver->getTitle(), 'source' => base64_encode($webDriver->getPageSource()) ] ], JSON_PRETTY_PRINT) ); // save the image $downloader->save(__DIR__ . '/images/'); // save the image in base64 format. // base64_decode to view the raw image data. $downloader->save(__DIR__ . '/images/', true); } TorLauncher::stop($torProcess);