• perl 爬取铜板街产品列表


    node2:/root/pachong/tongbanjie#cat tongbanjie.txt 
    <div class="listBox clearfix">
                                <div class="box clearfix">
                                                                            <div class="item">
                                    <div class="title"><a href="//trade.tongbanjie.com/trade/web/tbdaily/tongbao.html">铜宝</a>
                                    </div>
                                    <div class="income">
                                        <p class="tit gray">七日年化</p>
                                        <p class="numBox"><span class="num"></span>3.00<span
                                                class="symbol">%</span></p>
                                    </div>
                                    <div class="other tb-prod-tip-text">
                                        即刻起息,随时取现
                                    </div>
                                    <div class="progress">
                                        <div class="stripBox">
                                            <div class="strip" style="50%;"></div>
                                        </div>
                                        <div class="gray">长期在售</div>
                                    </div>
                                    <div class="btnBox">
                                        <a href="//trade.tongbanjie.com/trade/web/tbdaily/tongbao.html"
                                           class="buy btn">马上赚钱</a>
                                    </div>
                                </div>
                                                                                                    <div class="item  ">
                                                                        <span class="icon"><em>新手</em></span>
                                                                    <div class="title"><a
                                            href="//product.tongbanjie.com/detail/fa17022250409.html">新手专享543期</a>
                                    </div>
                                                                                                                                        <div class="income">
                                        <p class="tit gray">预期年化收益</p>
                                        <p class="numBox"><span class="num"></span>12.00<span class="symbol">%</span></p>
                                    </div>
                                    <div class="other">
                                        <div class="day floatleft">
                                            <span class="gray">理财期限</span>
                                            <span class="numBox"><em>14天</em></span>
                                        </div>
                                        <div class="buy floatright">
                                            <span class="gray">30天购买</span>
                                            <span class="numBox"><em> 52  </em>人</span>
                                        </div>
                                    </div>
    
                                                                                                                <div class="progress">
                                                <div class="stripBox">
                                                    <div class="strip"
                                                         style=" 22.70% ;"></div>
                                                </div>
                                                <div class="gray">
                                                                                                        已售
                                                                                                                22.70%
                                                                                                                                                    </div>
                                            </div>
                                                                                                        <div class="btnBox">
                                        <a href="//product.tongbanjie.com/detail/fa17022250409.html"
                                           class="buy btn"> 马上赚钱 </a>
                                    </div>
                                </div>
                                                                                                    <div class="item  ">
                                                                    <div class="title"><a
                     
    
    
     node2:/root/pachong/tongbanjie#cat t1.pl 
    use LWP::UserAgent;  
    use POSIX;  
    use HTML::TreeBuilder::XPath;   
    use Encode;   
    use HTML::TreeBuilder;    
    use Data::Dumper;
    use HTML::TreeBuilder::XPath;  
    use DBI;  
    use Encode;
       my $tree= HTML::TreeBuilder::XPath->new;  
                $tree->parse_file( "tongbanjie.txt");
                my @list= $tree->findvalues('/html/body//div[@class="box clearfix"]/div/div');
                foreach (@list){
                print "$_ is $_
    ";
                };
    node2:/root/pachong/tongbanjie#perl t1.pl 
    $_ is 铜宝
    $_ is 七日年化3.00%
    $_ is  即刻起息,随时取现 
    $_ is 长期在售
    $_ is 马上赚钱
    $_ is 新手专享543期
    $_ is 预期年化收益12.00%
    $_ is 理财期限 14天30天购买  52 人
    $_ is  已售 22.70% 
    $_ is  马上赚钱 
    $_ is 
    
    
    node2:/root/pachong/tongbanjie#cat  t1.pl 
    use LWP::UserAgent;  
    use POSIX;  
    use HTML::TreeBuilder::XPath;   
    use Encode;   
    use HTML::TreeBuilder;    
    use Data::Dumper;
    use HTML::TreeBuilder::XPath;  
    use DBI;  
    use Encode;
       my $tree= HTML::TreeBuilder::XPath->new;  
                $tree->parse_file( "tongbanjie.txt");
                my @list= $tree->findvalues('/html/body//div[@class="box clearfix"]/div');
                #my @list= $tree->findvalues('/html/body//div[@class="box clearfix"]/div/div');
                foreach (@list){
                print "$_ is $_
    ";
                };
    node2:/root/pachong/tongbanjie#perl t1.pl 
    $_ is 铜宝七日年化3.00% 即刻起息,随时取现 长期在售马上赚钱
    $_ is 新手新手专享543期预期年化收益12.00%理财期限 14天30天购买  52 人 已售 22.70%  马上赚钱 
    $_ is 

  • 相关阅读:
    HTML5中meta属性的使用详解
    前端部分兼容性问题汇总
    position元素定位详述
    jquery简单实现轮播图
    事件委托-选项卡案例
    async、await
    前端会遇到的算法
    arguments实参个数
    前端知识点整理(三)
    var、let、const
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349793.html
Copyright © 2020-2023  润新知