zoukankan      html  css  js  c++  java
  • 20140425

    首先是以虎嗅网分析为例。先对其RSS进行分析。这一步貌似是最简单的一步。但是我用了10个小时吧。

    技术就是使用XML:: Simple模块。我使用之后Data::Dumper()xml之后是一些这样的数据。和perldoc上与CPAN的不一样。

    我看了其他人的写解析XML博客貌似也没有我的这么复杂。

    今天的虎嗅RSS。:M

    xml 是通过 curl http://www.huxiu.com/rss/0.xml 获得的。

     
    RSS
     

     

    我的Dumper

    RSS

    我的解析代码。

    #!/usr/bin/perl

    use utf8;
    use Data::Dumper qw(Dumper);
    use XML::Simple;

    binmode STDOUT,"utf8";
    $Data::Dumper::Indent = 1 ;

    my $file_name = "huxiu-rss";
    unless(-e $file_name){
    print "$file_name is not exsit ";
    }
    open(DATA ,$file_name);
    binmode DATA,"utf8";

    my $xml = XML::Simple->new(ForceArray => 1);
    my $xml = $xml->XMLin(*DATA);

    my $channel = $xml->{"channel"};
    my $item = $channel->[0]{item};
    my $title0 = $item->[0]{title};

    print $len =  @$item," ";

    for $i (0 .. $len)
    {
    print $item->[$i]{title}->[0]," ";
    }
    close(DATA);

    今天有点累了,再加找工作太不顺心了,只能写个小东西来慰藉自己了。
     
     
     
     
     
     
     
     
  • 相关阅读:
    LeetCode:Validate Binary Search Tree
    二叉树的非递归遍历(非递归使用栈、非递归不使用栈)
    scala 基础语法
    scala VS python2 (linux or shell)
    web压力测试工具
    Elasticsearch cluster health: yellow unassigned shards
    GC overhead limit exceeded
    linux定时任务的设置
    linux CPU占用率高(转)
    JQuery Sparkline 说明文档
  • 原文地址:https://www.cnblogs.com/ppazhang/p/3687804.html
Copyright © 2011-2022 走看看