PHP code example of napoleon / crawl

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

    

napoleon / crawl example snippets

 php
use Napoleon\Crawler\DOMDocument;

$url = 'https://www.example.com';
$document = new DOMDocument($url);

print_r($document->html()->get());
 php
use Napoleon\Crawler\DOMDocument;

$url = 'https://www.example.com';
$document = new DOMDocument($url);
print_r($document->findByClass('anchor')->get());

 php
.array:2 [
  0 => array:3 [
    "tagName" => "a"
    "attributes" => array:2 [
      "class" => "anchor -success"
      "href" => "/redirect/now/1"
    ],
    "content" => "Link 1",
    "children" => null
  ]
  1 => array:3 [
    "tagName" => "a"
    "attributes" => array:2 [
      "class" => "anchor"
      "href" => "/redirect/now/2"
    ],
    "content" => "Link 2",
    "children" => null
  ]
]