【发布时间】:2015-08-14 14:34:56
【问题描述】:
我有显示我的新闻的新闻页面。我用表格来显示标题。
<table class="news">
<tr>
<th>#</th>
<th></th>
</tr>
<tr>...</tr>
<tr>...</tr>
</table>
我在此页面中还有其他表格。但我想在另一个页面中获取此表。我搜索并找到了这种方式:
$text = file_get_contents("http://www.example.com/news");
echo strip_tags($text, "<table><tr><th><td>");
输出包含新闻页面中的所有表格。我的目标只是带有“新闻”类的表格。
我该怎么做?
【问题讨论】:
-
我建议你使用 PHP DOMparser。
-
@Kristiyan 那么你能解释一下我该怎么做吗?那么也许你可以给我一个很好的参考。 tnx.
-
你能显示你的 html 响应吗?
标签: php html file-get-contents