用Perl写的股票机

      这是原先在ChinaUnix看到的一篇文章。

      

#!/usr/bin/perl -w

#By xti9er http://www.xtiger.net/

use LWP::Simple;
use Color::Output;
Color::Output::Init;

START:
system("cls");
`title  --= M y  S t o c k  S c r e e n e r =--`;
cprin("\tM y  S t o c k  S c r e e n e r\n\n",7);

cprin("_"x50,13);

$|=1;

if(my $googled=get("http://www.google.cn/finance/info?q=id-690158,id-684321,id-684268,id-697176,id-702734,id-684353,id-709933,id-706853,id-690427,id-697980&infotype=infoquoteall&hl=zh-CN&gl=cn"))
{
    my @info=split(/\,/,$googled);
    print "\n股票码\t开盘价\t最高价\t最低价\t涨跌\t名称\n";
    for my $newinfo(@info)
    {
        if ($newinfo=~/\"(.*)\"\s\:\s\"(.*)\"/)
        {
            my $infot=$1;
            my $infoc=$2;
            next if $infot=~/avvo|ccol|l_cur|lt|fwpe|beta|lo52|hi52/;
            if($infot eq "t"){$t=$infoc}
            if($infot eq "op"){$op=$infoc}
            if($infot eq "hi"){$hi=$infoc}
            if($infot eq "lo"){$lo=$infoc}
            if($infot eq "cp"){$cp=$infoc}
            if($infot eq "lname"){$lname=$infoc}            
            if ($infot eq "type")
            {
                print "$t\t";
                print "$op\t";
                cprin("$hi\t",($hi-$op)>0?5:7);
                cprin("$lo\t",($lo-$op)>0?5:7);
                cprin("$cp\t",$cp>0?5:7);
                print "$lname\n";
                print "-----------\n";
            }            
        }
    }
}
else
{
    cprin("\n[!] GetInfo Fail\n",5);
}

sleep 10;
goto START;
print "\n","+"x50,"\n";

sub cprin
{
    ($str,$i)=@_;
    cprint("\x03" . $i . " $str\x030");
}

      如果报告以下错误:

     Can't locate Color/Output.pm in @INC (@INC contains: D:/Perl/site/lib D:/Perl/li
b .) at gupiao line 6.
BEGIN failed--compilation aborted at gupiao line 6.


     需要安装Color::Output模块,去search.cpan.org网址下载,解压。多半可以用如下的方式安装:

     $ perl Makefile.pl

     $ make install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值