duanre1891 2011-04-01 16:52
浏览 200
已采纳

使用新的simple_html_dom获取链接和文本

Using new simple_html_dom

How I can get

  1. The Link

  2. The text(name)

    div class="stackoverflow" href="http://stackoverflow.com">Stackoverflow div

I think you use inner and outertext but I'm new to all of this so I thought I'll ask the experts.

Thanks

EDIT: I removed the anchor's as they where been parsed and turned into an actually link.

  • 写回答

1条回答 默认 最新

  • douying0108 2011-04-01 17:28
    关注

    From the simple_html_dom documentation: http://simplehtmldom.sourceforge.net/manual.htm

    $html = str_get_html('<div class="stackoverflow" href="http://www.stackoverflow.com">Stackoverflow Div</div>');
    
    $e = $html->find("div.stackoverflow");
    
    $link = $e->href;
    
    $name = $e->innertext;
    

    Obviously you can change the html input etc.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)