PHP code example of code-dragons / simple-crawler-php
1. Go to this page and download the library: Download code-dragons/simple-crawler-php 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/ */
code-dragons / simple-crawler-php example snippets
use SimpleCrawler\Crawler;
use SimpleCrawler/Crawler;
$crawler = new Crawler("<URL>");
$crawler->setRule("<regra_Xpath>");
$crawler->searchInformationByRule();
foreach( $crawler->getInformationsOfSearch() as $elementos)
{
echo $elementos;
}
Crawler\Crawler;
$crawler = new Crawler("https://www.climatempo.com.br/previsao-do-tempo/cidade/406/bauru-sp");
$crawler->setRule("//span[@id='min-temp-1']");
$crawler->searchInformationByRule();
echo "temperatura minima em Marilia: " . $crawler->getInformationsOfSearch()[0];
composer