无法使用简单的html dom检索内容

时间:2013-05-13 09:52:47

标签: php simple-html-dom

<div class="divHeaderContainer1">
<table width="488" cellspacing="0" cellpadding="0" height="63">
<tbody>
<tr>
<td height="61">
<a href="jobs/jobdetails.php?recordID=5300"> Job Vacancy For Media and Production      Officer At The International Committee of the Red Cross (ICRC)&nbsp; </a>
<div class="jobDate">posted on 2013-05-10&nbsp;&nbsp;|&nbsp;by Admin |&nbsp;0  comments&nbsp;|&nbsp; 379 views </div>
</td>
</tr>
</tbody>
</table>
</div>

我试图从一个网站(www.employmentng.com)检索href属性,代码如下,但它没有返回任何内容。

$url='http://www.employmentng.com/index.php?pageNum_Jobs=1&totalRows_Jobs=5127';
$html = file_get_html($url);

foreach($html->find('div[class=divHeaderContainer1]') as $container){
    foreach($html->find('table td[height]') as $table){
        foreach($table->find('a') as $link{
            echo $link-href;
        }

    }
}

我需要帮助

1 个答案:

答案 0 :(得分:0)

那里有语法错误。可能错误报告已关闭,所以

更改行

foreach($table->find('a') as $link{

到行

foreach($table->find('a') as $link) {

编辑:

还有一个错误:

echo $link-href;
echo $link->href;