PHP code example of capimichi / crawler

1. Go to this page and download the library: Download capimichi/crawler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

capimichi / crawler example snippets




use Crawler\Downloader\CacheDownloader;
use Crawler\Downloader\SimpleDownloader;

loader = new CacheDownloader($downloader, __DIR__ . "/var/cache/", ".html");
$mainCategoriesWebPage = new MainCategoriesWebPage($startUrl, $cacheDownloader);

$categoryUrls = $mainCategoriesWebPage->getCategoryUrls();

foreach ($categoryUrls as $categoryUrl) {

    do {
        $productsWebPage = new ProductsWebPage($categoryUrl, $cacheDownloader);

        $productUrls = $productsWebPage->getChildUrls();

        foreach ($productUrls as $productUrl) {
            $productWebPage = new ProductWebPage($productUrl, $cacheDownloader);
            $title = $productWebPage->getTitle();
        }

        $categoryUrl = $productsWebPage->getNextPageUrl();
    } while ($categoryUrl != null);
}