2013-02-17 27 views
0

好的,我在這裏很茫然。我是編程新手,無情地谷歌搜索,甚至在這裏提出這個問題,但無濟於事,所以我現在再試一次,我的研究工作稍微好一些。如何使用simple_html_dom獲取和打印meta標籤中的屬性

我需要檢索從什麼是「內容」屬性中的這行代碼的文本:

<meta property='og:title' content="title goes here" /> 

這是代碼,我至今不工作:

//saves the URL as HTML 
$movie_html = file_get_html($movie_url); 

//finds the title within the HTML 
$movie_title_meta = $movie_html->find("meta[name=og:title]"); 
$movie_title = $movie_title_meta->content; 

//prints the score 
var_dump($movie_title_meta); 

我想要的代碼是什麼給我的是:

title goes here 

而是我得到一個空的錯誤。我有一種感覺var_dump()實際上並不是我想要做的,但簡單的echo()也會返回錯誤。我只是不知道該怎麼做,所以任何幫助將非常感激。

在此先感謝!

回答

0

嘗試使用PHP簡單的HTML DOM解析器大衛·沃爾什... http://davidwalsh.name/php-notifications

+0

是否使用需要我添加任何東西到我的服務器或我可以用我已經使用它? – devirkahan 2013-02-17 19:38:42

+0

沒關係。它是我已經使用的simple_html_dom的一部分。它的作品!歡呼!我將永遠感激。 – devirkahan 2013-02-17 20:50:23