duanmei9980 2014-03-25 10:18
浏览 35
已采纳

Html Dom解析器得到第一个元素

Hi i'm using simple_html_dom php library to get contents from other website.

I have below html structure,

<h1 class="nik_product_title" style="color: #000;">
  DSLR D7100
  <span class="new_big_parent">
    <span class="new_big_child">
      <span class="new_big_child1">new</span>
    </span>
  </span>
</h1>

Using this

@$html->find ( 'div[class=nik_block_product_main_info_component_inner] h1',0)->plaintext;

But i'm getting output as DSLR+D7100new

How to get only first plain text i.e, need to fetch only DSLR D7100

  • 写回答

2条回答 默认 最新

  • douzen1896 2014-03-25 13:17
    关注

    You can actually get at that one with:

    $html->find('h1 text', 0);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀