public function handle(Spizer_Document $doc) { // Silently skip all non-HTML documents if (!$doc instanceof Spizer_Document_Html) { return; } // Add document URL to the list of visited pages $baseUrl = $doc->getUrl(); if (!in_array($baseUrl, $this->targets)) { $this->targets[] = $baseUrl; } $pagerize = new Diggin_Scraper_Helper_Simplexml_Pagerize(simplexml_import_dom($doc->getDomDocument()), array('baseUrl' => $this->toUrl($doc->getUrl()))); if ($nextLink = $pagerize->getNextLink()) { $max_follow = $this->_config['max_follow']; if (!$max_follow or $this->page_count <= $max_follow) { $this->addToQueue($nextLink, $baseUrl); ++$this->page_count; } } }