这是原先在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