PHP code example of tokimikichika / html-parser

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

    

tokimikichika / html-parser example snippets


use Tokimikichika\HtmlParser\HtmlParser;

$parser = new HtmlParser();
$html = $parser->fetch('https://example.com');
$title = $parser->getTitle($html);
$links = $parser->getLinks($html);

use Tokimikichika\HtmlParser\HtmlParser;
use RuntimeException;

$parser = new HtmlParser();

try {
    $html = $parser->fetch('https://invalid-host');
} catch (RuntimeException $e) {
}