PHP code example of asymptix / php-html-dom-parser

1. Go to this page and download the library: Download asymptix/php-html-dom-parser 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/ */

    

asymptix / php-html-dom-parser example snippets


use Asymptix\HtmlDomParser\HtmlDomParser;

 = new HtmlDomParser();
$html->loadUrl($url);
foreach ($html->find("a.product") as $productItem) {
    $productHtml = new HtmlDomParser();
    $productHtml->loadUrl($productItem->href);

    $productDetails = $productHtml->find("div#productDetails", 0);
    $productForm = $productHtml->find("div#productForm", 0);

    $product = new stdClass();

    if (is_object($productForm)) {
        $product->price = $productForm->find("div.price", 0)->plaintext;
    }

    unset($productHtml);
}
json
{
	"minimum-stability": "dev",
    "hp-html-dom-parser": "1.5.*"
    }
}