用perl写了的获取基金信息
2007-07-19 阅读 140
```
#! /usr/bin/perl
system('clear');
%alls = ("050008", "博时第三", "110010", "易基价值", "160311", "华夏蓝筹", "202003", "南方绩优", "310328", "新动力");
use LWP::Simple;
$str = get("http://funds.eastmoney.com/bzdm.html");
@dt = ( $str =~ m%\d{4}-\d{1,2}-\d{1,2}%sg);
my $outt = $dt[0];
my $outy = $dt[2];
@list = ( $str =~ m%<tr height=20>.+?</tr>%sg );
my $num = 1;
foreach (@list)
{
#print $num . "----------------------------------\n";$num = $num + 1;
$_ =~ m%<tr height=20><td>(.+?)</td>%s;
$id = $1;
$_ =~ m%<td>(\d{6})</td>%s;
$code = $1;
$_ =~ m%">(.+?)<font%s;
$name = $1;
$name =~ s/ \;//;
$_ =~ m%<td>(\d\.\d{4}|---)</td>%s;
$tm = $1;
$_ =~ m%<td class="TD2">(\d\.\d{4}|---)</td>%s;
$ym = $1;
$_ =~ m%<font color='ff0000'>(.+?)</font>%s;
$ud = $1;
if( exists $alls{$code} )
{
$outt = $outt . ',' . $alls{$code} . $tm;
$outy = $outy . ',' . $alls{$code} . $ym;
}
}
print $outy . "\n";
print $outt . "\n";
```
perl 学习笔记
更新于 2023年03月28日