PHP code example of cloudstudio / laravel-html-crawler
1. Go to this page and download the library: Download cloudstudio/laravel-html-crawler 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/ */
cloudstudio / laravel-html-crawler example snippets
use CloudStudio\HtmlCrawler\Facades\HtmlCrawler;
$html = "Line 1\nLine 2";
$cleanHtml = HtmlCrawler::fromHtml($html)
->preserveNewlines(false) // Set to false to replace newlines with spaces
->clean();
// Expected output: "Line 1 Line 2"
use CloudStudio\HtmlCrawler\Facades\HtmlCrawler;
$cleanHtml = HtmlCrawler::fromUrl('https://example.com')
->clean();
// Output: the cleaned HTML content retrieved from the URL.