SimpleHtmlDom找到td值

时间:2018-02-16 14:51:13

标签: php simple-html-dom

使用Simplehtmldom,我如何访问"文件号"的值? &安培; "网站地址"在下面的行中,将它们分配给变量。我尝试了尽可能多的方法,但似乎无法破解它。任何帮助都将受到赞赏。 提前致谢

 <table summary="Results of the Search" class="display_table" 
  cellspacing="2" cellpadding="4">
  <tbody>
  <tr class="Row1">
    <td title="View Application Details" class="TableData">
      <a class="data_text" href="StdDetails.aspx?PT=Planning Applications On-Line&amp;TYPE=PL/PlanningPK.xml&amp;PARAM0=
                                    606013&amp;XSLT=
                                    /Northgate/PlanningExplorer/SiteFiles/Skins/EppingForest/xslt/PL/PLDetails.xslt&amp;FT=Planning Application Details&amp;PUBLIC=
                                    Y&amp;XMLSIDE=/Northgate/PlanningExplorer/SiteFiles/Skins/EppingForest/Menus/PL.xml&amp;DAURI=PLANNING
                                ">EPF/0480/18/NEW</a>
    </td>
    <td class="data_text" title="File Number">018049</td>
    <td class="data_text" title="Site Address">Hoggs Farm
Carters Green Road
Matching
Harlow
CM17 0NX</td>
    <td class="data_text" title="Development Description">Grade II listed building application for proposed extension</td>
    <td class="data_text" title="Status">NEW</td>
    <td class="data_text" title="Date Registered">--</td>
    <td class="data_text" title="Decision"></td>
  </tr>

        $output = curl_exec($ch);
        $html = str_get_html($output);

            $display_rows = $html->find('table[class=display_table]',0)->find('tr');  
            if(count($display_rows)>0)
                foreach($display_rows as $row)
                {
                    $tds = $row->find('td');
                    if(count($tds)==0)
                        continue;

                    $data = array();
                        foreach($tds as $td)
                    {

                               if($td->title=="File Number")
                        {
                           $filenumbertd = $td->children(1);
                    $filenumber= $filenumbertd;
                    echo $filenumber.'<br>';
                               }
                                }
                                 }
                planning_scrape( 1 );


        ?>

        </body>
        </html>

0 个答案:

没有答案
相关问题