【发布时间】:2014-05-18 12:54:38
【问题描述】:
我在变量 $html 中使用这一行获取页面的源代码:
$html = file_get_contents('http://www.google.com');
当我这样做时<textarea><?php echo htmlentities($html); ?></textarea>
效果很好。
现在,假设我想取出页面中的每个<h1> 标记,其内容在变量 $h1 中,我该如何从 $html 变量中执行此操作?
【问题讨论】:
-
您需要使用 DOMParser。 php.net/manual/en/book.dom.php请尝试一些方法,以便我们为您提供帮助..
标签: php html file file-get-contents