PHP code example of diaslasd / busca_cursos

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

    

diaslasd / busca_cursos example snippets




use Alura\BuscadorDeCursos\Buscador;
use GuzzleHttp\Client;
use Symfony\Component\DomCrawler\Crawler;

$client = new Client(['verify' => false]);
$crawler = new Crawler();
$url = 'https://www.alura.com.br/cursos-online-programacao/php';
$filtro = 'span.card-curso__nome';

$buscador = new Buscador($client, $crawler);
$cursos = $buscador->buscar($url, $filtro);

foreach ($cursos as $curso) {
    echo $curso->textContent . PHP_EOL;
}