PHP code example of jerodev / diggy

1. Go to this page and download the library: Download jerodev/diggy 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/ */

    

jerodev / diggy example snippets


$client = new \Jerodev\Diggy\WebClient();
$page = $client->get('https://www.deviaene.eu/');

$socials = $page->first('#social')->querySelector('a span')->texts();
var_dump($socials);

//    [
//        'GitHub',
//        'Twitter',
//        'Email',
//        'LinkedIn',
//    ]

$nodes->attribute('href');

$nodes->count();

$nodes->each('a', static function (NodeFilter $node) {
    return $a->attribute('href');
});

$nodes->exists('a.active');

$nodes->filter(static function (NodeFilter $node) {
    return $node->text() === 'foo';
});

$nodes->first('a.active');

$nodes->is('div');

$nodes->last('a.active');

$nodes->nodeName();

$nodes->nth(1, 'a.active');

$nodes->querySelector('a.active');

$nodes->text('p.description');

$nodes->texts('nav > a');

$nodes->whereHas(static function (NodeFilter $node) {
    return $node->first('a[href]');
});

$nodes->whereHasAttribute('href');

$nodes->whereHasText('foo');

$nodes->xPath('//nav/a[@href]');