1. Go to this page and download the library: Download shamanhead/phpporser 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/ */
shamanhead / phpporser example snippets
use HeadlessChromium\Page;
use ShamanHead\PhpPorser\App\Dom as Dom;
$dom = new Dom();
$dom->setHref('file:///home/shamanhead/dev/porser/phpporser-master/test.html');
$dom->setBrowserPath('PATH_TO_CHROME');
hamanHead\PhpPorser\App\Dom as Dom;
$dom = new Dom();
$dom->setHref('https://en.wikipedia.org/wiki/Computer_science');
print_r($dom->tag('h1')->class('firstHeading')->text()->merge());
hamanHead\PhpPorser\App\Dom as Dom;
$dom = new Dom();
$dom->setHref('href to file');
print_r($dom->tag('h1')->array()); //finds by tag name 'h1'
print_r($dom->id('firstHeading')->array()); //finds by id name 'firstHeading'
print_r($dom->class('wrapper__main')->array()); //finds by class name 'wrapper_main'
print_r($dom->custom(['name', 'button'])->array()); //finds by 'name' attribute value 'button'
hamanHead\PhpPorser\App\Dom as Dom;
$dom = new Dom();
$dom->setHref('href to file');
print_r($dom->class('main')->id('firstHeading')->tag('h1')->array());
hamanHead\PhpPorser\App\Dom as Dom;
$dom = new Dom();
$dom->setHref('href to file');
$divText = $dom->tag('div')->id('someDiv')->text();
$divText->contents(); //Returns all text in array form.
$divText->merge('symbol'); //Returns all text in string form with 'symbol' separator
//'\n' by default.
$divText->first(); //Returns first founded text.
$divText->last(); //Returns last founded text.
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.