【发布时间】:2012-01-17 10:31:36
【问题描述】:
我正在尝试使用 PHP Simple HTML Dom Parser 从网站检索一些信息。在网站上有许多带有“forumborder2”类的表格,在其中我想获取一些信息。在下一个示例中,我想要图像源。
<table class="forumborder2" width=100% cellspacing=0 cellpadding=0 border=0 align=center>
<tr>
<td class="titleoverallheader2" background="modules/Forums/templates/chunkstyle/imagesnew/forumtop.jpg" style="border-top:0px; border-left:0px; border-right:0px;" width="100%" colspan=7 Align=left>
<b>Supernatural </b>(2005) - Enviada por: <b>AlJoSi</b> em 6 de Dezembro, 2011 (22:35:11)
</td>
</tr>
<tr height=25>
<td class="colour12" align=right width=100>
<b>Idioma:</b>
</td>
<td width=110 class="colour22">
<img src="modules/Requests/images/fPortugal.png" width=18 height=12 border=0 alt='' title=''>
</td>
</tr> </table>
我做了以下事情:
foreach($html->find('table[class="forumborder2"]')as $tr){
echo $tr->children(1)->children(1)->src; }
这总是给出错误:“试图获取非对象的属性”。如果我只去$tr->children(1)->children(1) 我可以得到<img src="modules/Requests/images/fPortugal.png" width=18 height=12 border=0 alt='' title=''> 那为什么我不能访问 src 属性。
【问题讨论】:
-
什么是“简单的 HTML dom 解析器”? 什么错误???
-
@Jon, PHP Simple HTML DOM Parser。也更改了错误的帖子。
标签: php simple-html-dom