2013-05-13 74 views
-1
<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屬性,但它沒有返回任何內容。無法用簡單的html dom檢索內容

$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

任何機會你的意思是'$ container-> find(「table ...」)'而不是'$ html-> find(「table ...」)'? – Passerby 2013-05-13 09:57:15

+0

我的意思是$ container-> find('table ...) – 2013-05-13 10:19:30

回答

0

你有一個語法錯誤有幫助。大概錯誤報告功能已關閉,因此

行更改

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

排隊

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

編輯:

多了一個錯誤在那裏:

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