PHP Notice: Undefined variable: response in D:\Trabalho\Aulas\ALURA\PHP\Composer\buscar-cursos.php on line 11
Notice: Undefined variable: response in D:\Trabalho\Aulas\ALURA\PHP\Composer\buscar-cursos.php on line 11 PHP Fatal error: Uncaught Error: Call to a member function getBody() on null in D:\Trabalho\Aulas\ALURA\PHP\Composer\buscar-cursos.php:11 Stack trace:
#0 {main} thrown in D:\Trabalho\Aulas\ALURA\PHP\Composer\buscar-cursos.php on line 11
Fatal error: Uncaught Error: Call to a member function getBody() on null in D:\Trabalho\Aulas\ALURA\PHP\Composer\buscar-cursos.php:11 Stack trace:
#0 {main} thrown in D:\Trabalho\Aulas\ALURA\PHP\Composer\buscar-cursos.php on line 11
------------------Meu código-------------- <?php
require 'vendor/autoload.php';
use GuzzleHttp\Client; use Symfony\Component\DomCrawler\Crawler;
$client = new Client(['verify' => false]); $resposta = $client->request('GET','https://www.alura.com.br/cursos-online-programacao/php');
$html = (string) $response->getBody(); $crawler = new Crawler($html); $crawler->addHtmlContent(($html));
$cursos = $crawler->filter('span.card-curso__nome');
foreach ($cursos as $curso){ echo $curso->textContent . PHP_EOL; }