1. Go to this page and download the library: Download lalbert/daric 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/ */
lalbert / daric example snippets
use Daric\Scraper;
use Daric\Extractor\CrawlerExtractorFactory;
$scraper = new Scrapper('http://website.tld');
$scraper->setExtractors([
'meta_title' => CrawlerExtractorFactory::create('title@_text'), // get text node of <title></title>
'meta_description' => CrawlerExtractorFactory::create('meta[name="description"]@content'), // get attribute "content" of <meta name="description" />
'list' => CrawlerExtractorFactory::create('#content ul.list li@_text("array")') // get all text node of li item. Return an array
]);
$doc = $scraper->scrape(); // return Daric\Document
echo $doc->getData('meta_title');
print_r($doc['list']);
use Daric\Spider;
use Daric\Scraper;
use Daric\Extractor\CrawlerExtractorFactory;
$spider = new Spider('http://website.tld');
$spider->setLinkExtractor(CrawlerExtractorFactory::create('#content article a.link@href("array")'));
$spider->setNextLinkExtractor(CrawlerExtractorFactory::create('#nav a.next@href'));
foreach ($spider as $pageUri) {
$scraper = new Scraper($pageUri, $extractors, $cleaners, $formatters);
$doc = $scraper->scrape();
...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.