zoukankan      html  css  js  c++  java
  • perl 根据div 标签 查找id属性的值

    node2:/root/pachong#cat test.html 
        <div id="xxoo" class="pagelist">
    <span> 159条  共8页</span><strong>1</strong> <a href="/zhaoyangjian724/article/category/1756685/2">2</a> <a href="/zhaoyangjian724/article/category/1756685/3">3</a> <a href="/zhaoyangjian724/article/category/1756685/4">4</a> <a href="/zhaoyangjian724/article/category/1756685/5">5</a> <a href="/zhaoyangjian724/article/category/1756685/6">...</a> <a href="/zhaoyangjian724/article/category/1756685/2">下一页</a> <a href="/zhaoyangjian724/article/category/1756685/8">尾页</a> 
        </div>
    
    </div>
    
    
    node2:/root/pachong#cat a5.pl 
     use HTML::TreeBuilder::XPath;  
     my $tree= HTML::TreeBuilder::XPath->new;  
     $tree->parse_file( "test.html");
       ##获取博客分类的URL,根据a标签查找属性为href  
      @Links = $tree->find_by_tag_name('div');  
      #print Dumper($Links[0]);
      print "--------------------
    ";
      print $Links[0]->attr('id'); 
      print "
    ";
    
    
    node2:/root/pachong#perl a5.pl 
    --------------------
    xxoo
    
    
      @Links = $tree->find_by_tag_name('div');
    
      根据div 标签 查找id属性的值
    
    
      print $Links[0]->attr('id'); 
    
      
      node2:/root/pachong#cat a5.pl 
     use HTML::TreeBuilder::XPath;  
     my $tree= HTML::TreeBuilder::XPath->new;  
     $tree->parse_file( "test.html");
       ##获取博客分类的URL,根据a标签查找属性为href  
      @Links = $tree->find_by_tag_name('div');  
      #print Dumper($Links[0]);
      print "--------------------
    ";
      print $Links[0]->attr('id'); 
      print "
    ";
    
    
      node2:/root/pachong#perl a5.pl 
      --------------------
      xxoo

  • 相关阅读:
    ReportingServices报表管理器实现订阅
    sharepoint部署
    在sharepoint工程中添加引用
    asp:DropDownList选择事件出错
    ETL项目
    javascript refresh page 刷新页面的几种方法(转)
    innerHtml 和 innerText用法:(转载)
    用JavaScript隐藏控件的方法(转)
    JS中onpropertychange事件和onchange事件区别
    Window 对象
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349807.html
Copyright © 2011-2022 走看看