From ec15b7cb743482fb04de8c5b07c8dada7661a501 Mon Sep 17 00:00:00 2001 From: Michal Paulovic Date: Mon, 27 Oct 2014 10:19:43 +0100 Subject: [PATCH] Cache pre parsovanie HTML --- src/Csfd/Parsers/Parser.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Csfd/Parsers/Parser.php b/src/Csfd/Parsers/Parser.php index db1c5e8..3b42377 100644 --- a/src/Csfd/Parsers/Parser.php +++ b/src/Csfd/Parsers/Parser.php @@ -10,6 +10,8 @@ abstract class Parser { + static protected $_crawlers = []; + protected function match($subject, $pattern) { $matches = []; @@ -39,7 +41,14 @@ protected function splitByBr($text) protected function getNode($html, $xpath) { - $nodes = new Crawler($html); + $hash = md5($html); + if (!isset(static::$_crawlers[$hash])) + { + $nodes = new Crawler($html); + } else { + $nodes = static::$_crawlers[$hash]; + } + $filtered = $nodes->filterXPath($xpath); if ($filtered->count() === 0) {