PHP code example of yangqi / htmldom

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

    

yangqi / htmldom example snippets


'providers' => array(
    ...
	'Yangqi\Htmldom\HtmldomServiceProvider',
    ...

'aliases' => array(	
    ...
	'Htmldom' => 'Yangqi\Htmldom\Htmldom',
    ...

$html = new \Htmldom('http://www.example.com');

// Find all images 
foreach($html->find('img') as $element) 
       echo $element->src . '<br>';

// Find all links 
foreach($html->find('a') as $element) 
       echo $element->href . '<br>';