• 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

  • 相关阅读:
    filter
    验证
    HTML5 canvas 内部元素事件响应
    canvas 椭圆
    计算2点角度
    复制pdf文字出来是乱码的一种可能的解决方案
    LaTeX Pdf to Word
    论文题录导入导出的困惑
    公式测试
    [LaTex]Visio文件转EPS文件[转]
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349807.html
Copyright © 2020-2023  润新知