I have a code that should take the title of the page example "Facebook - enter or sign up" but that is giving error in this line
$title = $dom->getElementsByTagName('title')->item('0')->nodeValue;
this is the code:
function website_title($urli) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $urli); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // define um usuário agente. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36'); $html = curl_exec($ch); curl_close($ch); $dom = new DOMDocument; @$dom->loadHTML($html); $title = $dom->getElementsByTagName('title')->item('0')->nodeValue; return $title; } echo website_title('https://www.facebook.com/');
If anyone can help me, I'm grateful.