donglan9517 2018-02-16 14:51
浏览 39

SimpleHtmlDom找到td值

Using Simplehtmldom, how would I access the values of both "file number" & "site address" in the rows below, assign them to variables .I have tried as many ways as I can think of, but just cant seem to crack it.Any help would be appreciated. Thanks in advance

 <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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP