當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Crawler::crawl方法代碼示例

本文整理匯總了PHP中Crawler::crawl方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crawler::crawl方法的具體用法?PHP Crawler::crawl怎麽用?PHP Crawler::crawl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Crawler的用法示例。


在下文中一共展示了Crawler::crawl方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: crawlForNews

 /**
  * Start the crawler to retrieve pages from a given news website
  * @param type $nrOfDaysBack The nr of days the crawler should go back (counting from today)
  * @param type $newsSiteUrl The root URL of the news site (the seed of the crawler)
  * @return type
  */
 public function crawlForNews($nrOfDaysBack, $newsSiteUrl, $timeToLive, $startDate = null)
 {
     $crawler = new Crawler($newsSiteUrl, $timeToLive);
     if ($startDate) {
         $crawler->crawl($nrOfDaysBack, $startDate);
     } else {
         $crawler->crawl($nrOfDaysBack);
     }
     return count($crawler->getCrawled());
 }
開發者ID:Bram9205,項目名稱:WebInfo,代碼行數:16,代碼來源:Main.php

示例2: getHotSpots

 public function getHotSpots()
 {
     $crawler = new Crawler($this);
     $outlines = new CrawlerOutlineCollection();
     $size = $this->image->size();
     for ($x = 0; $x < $size[0]; $x++) {
         for ($y = 0; $y < $size[1]; $y++) {
             $pixel = $this->pixel($x, $y);
             // Skip white pixels
             if ($pixel->color()->compare(ImageColor::white(), 5)) {
                 continue;
             }
             // Skip crawled areas
             if ($outlines->contains($pixel)) {
                 continue;
             }
             // Start crawling
             $outline = $crawler->crawl($x, $y);
             $outlines->push($outline);
         }
     }
     $hotspots = new ImageCollection();
     foreach ($outlines as $outline) {
         $hotspots->push($this->image->sliceByOutline($outline));
     }
     return array($hotspots, $outlines);
 }
開發者ID:passbolt,項目名稱:passbolt_selenium,代碼行數:27,代碼來源:imagepixelmatrix.php

示例3: crawl

 /**
  * Parsing
  *
  * @throws Exception
  */
 public function crawl($url)
 {
     $crawler = new Crawler();
     $crawler->on($crawler::EVENT_HIT_CRAWL, function ($href, DOMDocument $dom) {
         $start = microtime(true);
         $imgLength = $dom->getElementsByTagName('img')->length;
         $time = microtime(true) - $start;
         $processTime = sprintf('%.6F', $time);
         $this->report[] = ['href' => $href, 'imgLength' => $imgLength, 'processTime' => $processTime];
         $this->show('  - ' . $href . ' [img: ' . $imgLength . ']' . PHP_EOL);
     });
     $crawler->on($crawler::EVENT_BEFORE_CRAWL, function () {
         $this->show('Start crawl' . PHP_EOL);
     });
     $crawler->on($crawler::EVENT_AFTER_CRAWL, function () {
         $this->show('Finish crawl' . PHP_EOL);
     });
     $crawler->crawl($url);
 }
開發者ID:kazak,項目名稱:test,代碼行數:24,代碼來源:Application.php

示例4: define

    define('DIR_ROOT', dirname(__FILE__));
}
if (!defined('DIR_KVZLIB')) {
    $lookIn = array('/Users/kevin/workspace/kvzlib', '/home/kevin/workspace/kvzlib', DIR_ROOT . '/ext/kvzlib');
    foreach ($lookIn as $dir) {
        if (is_dir($dir) && file_exists($dir . '/kvzlib.php')) {
            define('DIR_KVZLIB', $dir);
            break;
        }
    }
    if (!defined('DIR_KVZLIB')) {
        trigger_error('KvzLib not found in either: ' . implode(', ', $lookIn), E_USER_ERROR);
    }
}
define('IMDBPHP_CONFIG', DIR_ROOT . '/config/imdb.php');
ini_set("include_path", DIR_KVZLIB . ":" . DIR_ROOT . ":" . ini_get("include_path"));
require_once DIR_KVZLIB . '/php/classes/KvzShell.php';
require_once DIR_KVZLIB . '/php/classes/KvzHTML.php';
require_once DIR_KVZLIB . '/php/all_functions.php';
require_once DIR_ROOT . '/libs/crawler.php';
require_once DIR_ROOT . '/libs/movie.php';
require_once DIR_ROOT . '/libs/store.php';
require_once 'imdb.class.php';
$outDir = '/home/kevin/Dropbox/Public/cinema';
$outFile = 'kijken.html';
$crawlerOptions = array('dir' => '/data/moviesHD', 'minSize' => '600M', 'cachedir' => DIR_ROOT . '/cache', 'photodir' => $outDir . '/images');
$Crawler = new Crawler($crawlerOptions);
$movies = $Crawler->crawl();
$Store = new Store($movies, 'html', array('photovirt' => 'images', 'outputdir' => $outDir, 'outputfile' => $outFile, 'separate_on_dir' => 1));
$Store->save();
#$Store->output();
開發者ID:joericochuyt,項目名稱:kvzlib,代碼行數:31,代碼來源:moviexplore.php

示例5: extractContent

 /**
  * @param string $url
  * @param string $rawHTML
  */
 public function extractContent($url, $rawHTML = null)
 {
     $crawler = new Crawler($this->config);
     $article = $crawler->crawl($url, $rawHTML);
     return $article;
 }
開發者ID:scotteh,項目名稱:php-goose,代碼行數:10,代碼來源:Client.php

示例6: generate

 /**
  * Generate sitemap
  *
  * @return $this
  */
 public function generate()
 {
     $this->crawler->crawl();
     foreach ($this->crawler->getFoundUrls() as $url => $status) {
         if ($status == \Magelight\Sitemap\Models\Crawler::STATUS_SUCCESS) {
             $this->urls[] = ['loc' => $url, 'priority' => $this->getUrlPriority($url), 'changefreq' => $this->getUrlChangeFrequency($url)];
         }
     }
     return $this;
 }
開發者ID:rganin,項目名稱:magelight,代碼行數:15,代碼來源:Sitemap.php


注:本文中的Crawler::crawl方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。