0

好吧,我在这里不知所措。我是编程新手,一直在谷歌上搜索,甚至在这里问过这个问题,但无济于事,所以我现在再试一次,因为我研究得更好了。

我需要从这行代码的“内容”属性中检索文本:

<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

但相反,我得到一个 NULL 错误。我有一种感觉 var_dump() 实际上并不是我想要做的,但一个简单的 echo() 也会返回错误。我现在不知道该怎么做,所以任何帮助都将不胜感激。

提前致谢!

4

1 回答 1

0

尝试使用 David Walsh 的 PHP Simple HTML DOM Parser ... http://davidwalsh.name/php-notifications

于 2013-02-17T18:39:24.333 回答