Olá! Estou recebendo o seguinte erro ao tentar executar o buscador de cursos:
PHP Fatal error: Uncaught Symfony\Component\CssSelector\Exception\SyntaxErrorException: Unclosed/invalid string at 27. in C:\Users\BIANCA.FIALHO\Documents\curso php\php composer\vendor\symfony\css-selector\Exception\SyntaxErrorException.php:47
Meu código:
<?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('https://cursos.alura.com.br/formacao-desenvolvedor-php');
$cursos = $crawler->filter('span.learning-content__name"');
foreach($cursos as $curso) {
echo $curso->textContent . PHP_EOL;
}
O arquivo CSS selector para onde o erro aponta:
class SyntaxErrorException extends ParseException
{
/**
* @return self
*/
public static function unexpectedToken(string $expectedValue, Token $foundToken)
{
return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken));
}
/**
* @return self
*/
public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation)
{
return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation));
}
/**
* @return self
*/
public static function unclosedString(int $position)
{
return new self(sprintf('Unclosed/invalid string at %s.', $position));
}
Obrigada!