0
我想从外部页面链接源获取标题,说明。当我尝试获取Facebook页面源并正在返回某个其他页面的源代码时,这不起作用。它工作在其他网站像谷歌等。这里是我的PHP代码:从外部页面链接获取“标题”和“描述”
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
public function previewLink(){
$url = "https://www.facebook.com/NASA/";
$html = $this->file_get_contents_curl($url);
$title = "";
$description ="";
$image = "";
//parsing begins here:
$doc = new \DOMDocument();
@$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
$title = $nodes->item(0)->nodeValue();
}
我没有得到什么,我所面临的问题。有人能提出一些建议吗提前致谢。
谢谢。它正在工作。 – Ishan