_debug; } final public function setDebug(bool $debug): void { $this->_debug = $debug; } final public function createCrawler($html) { return new Crawler($html); } final public function getInnerHTML(string $html, $tag = false) { return $tag ? $this->createCrawler($html)->filter($tag)->html() : $this->createCrawler($html)->html(); } public function getLinks(Crawler $crawler, array $options = ["tag" => "a", "attr" => "href"]): array { $links = $crawler->filter($options["tag"])->each( function (Crawler $node) use (&$options) { return [ "anchor" => $node->text(), "href" => $node->attr($options["attr"]) ]; } ); foreach ($links as $link) { log_message("debug", "Link-> " . $link['href']); } return $links; } public function getImages(Crawler $crawler, array $options = ["tag" => "img", "attr" => "src"]): array { $images = $crawler->filter($options["tag"])->each( function (Crawler $node) use (&$options) { return [ "alt" => $node->attr('alt'), "src" => $node->attr($options["attr"]) ]; } ); foreach ($images as $image) { log_message("debug", "Image-> " . $image['src']); } return $images; } public function getVideos(Crawler $crawler, array $options = ["tag" => "video", "attr" => "src"]): array { $videos = $crawler->filter($options["tag"])->each( function (Crawler $node) use (&$options) { return [ "alt" => $node->attr('alt'), "src" => $node->attr($options["attr"]) ]; } ); foreach ($videos as $video) { log_message("debug", "Video-> " . $video['src']); } return $videos; } }