Beispiel #1
0
 /**
  * @param $startUrl
  * @param $maxLevel
  * @param $filePath
  */
 public function generate($startUrl, $maxLevel, $filePath)
 {
     $this->startUrl = $startUrl;
     try {
         $this->storage->init();
         $this->siteProcessor->setMaxLevel($maxLevel);
         $this->siteProcessor->process($startUrl);
         $this->writer->write($startUrl, $filePath);
         $this->storage->deInit();
     } catch (loader\LoaderException $e) {
         echo $e->getMessage();
     } catch (parser\ParserException $e) {
         echo $e->getMessage();
     } finally {
         $this->storage->deInit();
     }
 }
 /**
  * @param $url
  * @param $currentLevel
  * @throws loader\LoaderException
  * @return array
  */
 private function processUrl($url, $currentLevel)
 {
     $html = $this->loader->load($url);
     $normalizedUrls = UrlHelper::normalizeUrls($this->parser->getUrls($html), $this->mainPage, $url);
     return $this->storage->add($normalizedUrls, $currentLevel);
 }