I am trying to extract the title text from an html page and insert it into an object. I am using symphony and php. The result from filterXPATH
does not seem to be plain text and instead it is the entire html page and throwing error. I don't know why.
My code is:
$html = $this->file_get_contents_curl("http://www.google.com/");
$urlData = [];
$crawler = new Crawler($html);
$urlData->title = $crawler->filterXPath('//title')->extract('_text');
I see the title text if I do:
return $crawler->filterXPath('//title')->extract('_text');