1. Go to this page and download the library: Download 2upmedia/scout 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/ */
2upmedia / scout example snippets
$queryHandler = new Xpath(Html::parseDocument(file_get_contents('./tests/fixtures/header-and-table.html')));
$titlesAndPrices = (new DataPoint())->setQueryHandler($queryHandler);
$data = $titlesAndPrices
->setCollection('//table/tr')
->forKey('title')->set('./td[1]') // each tr is used as a context, so the key selectors should use "." to be relative to it
->forKey('price')->set('./td[2]')
->getData();
/*
array (
0 =>
array (
'title' => 'Title #1',
'price' => '$10.00',
),
1 =>
array (
'title' => 'Title #2',
'price' => '$23.20',
),
2 =>
array (
'title' => 'Title #3',
'price' => '$1.00',
),
3 =>
array (
'title' => 'Title #4',
'price' => '$5.00',
),
)
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.