Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

PHP Fatal error: Uncaught GuzzleHttp

Olá, estou com este problema que, vi outros tópicos com algo parecido, mas não conseguir achar a solução ainda.

<?php

require "vendor\autoload.php";

use GuzzleHttp\Client;
use Symfony\Component\DomCrawler\Crawler;

$client = new Client();
$resposta = $client->request('GET', 'https://cursos.alura.com.br/formacao-desenvolvedor-php');

$html = $resposta->getBody();

$crawler = new Crawler();
$crawler->addHtmlContent($html);

$cursos = $crawler->filter('span.learning-content__name');

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

No terminal recebo este aviso de erro:

PS C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura> php buscar-cursos.php PHP Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://cursos.alura.com.br/formacao-desenvolvedor-php in C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:211 Stack trace:

#0 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(158): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)

#1 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(110): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))

#2 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(47): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))

#3 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(28): GuzzleHttp\Handler\CurlHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)

#4 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Handler\Proxy.php(48): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler{closure}(Object(GuzzleHttp\Psr7\Request), Array)

#5 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\PrepareBodyMiddleware.php(35): GuzzleHttp\Handler\Proxy::GuzzleHttp\Handler{closure}(Object(GuzzleHttp\Psr7\Request), Array)

#6 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Middleware.php(31): GuzzleHttp\PrepareBodyMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)

#7 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\RedirectMiddleware.php(71): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Request), Array)

#8 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Middleware.php(63): GuzzleHttp\RedirectMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)

#9 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\HandlerStack.php(75): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Request), Array)

#10 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Client.php(331): GuzzleHttp\HandlerStack->__invoke(Object(GuzzleHttp\Psr7\Request), Array)

#11 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Client.php(168): GuzzleHttp\Client->transfer(Object(GuzzleHttp\Psr7\Request), Array)

#12 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Client.php(187): GuzzleHttp\Client->requestAsync('GET', Object(GuzzleHttp\Psr7\Uri), Array)

#13 C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\buscar-cursos.php(9): GuzzleHttp\Client->request('GET', 'https://cursos....')

#14 {main} thrown in C:\Users\PICHAU\Documents\Aulas Alura\Aula PHP\Composer\Buscador-cursos-alura\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 211

1 resposta
solução!

Insira aqui a descrição dessa imagem para ajudar na acessibilidade