返回列表 发帖
$html="http://www.baidu.com/s?wd=美元汇率";
$rcd="E:/R_记录/汇率记录.txt";
open WRITE,">>$rcd" or warn "$!";
system("wget -O main.txt $html 2>nul >nul");
open READ,"<main.txt" or warn "File not exists\n";
foreach (<READ>) {
        if (/(1美元=.*人民币元)/) {
                print "$&\n";
                print WRITE "$&  ";
                if (/汇率数据由和讯外汇提供,更新时间:(\d+)-(\d+)-(\d+)/) {
                        print "$&\n\n";
                        print WRITE "${1}-${2}-${3}\n";
                }
        }
}
close WRITE;
$html="http://www.baidu.com/s?wd=汇率";
system("wget -O main.txt $html 2>nul >nul");
open READ,"<main.txt" or warn "File not exists\n";
foreach (<READ>) {
        if (/(更新时间.*\d:\d+)/) {
                print "$&\n";
                foreach $a (0..5) {
                        if ($_=~s#.*?<th.*?>(.*?)</th>##i) {
                                $arr1[$a]=$1;
                        }
                }
                foreach $a (0..5) {
                        if ($_=~s#.*?<td.*?>(.*?)</td>##i) {
                                printf "%-10s \t\t%s\n",$arr1[$a],$1;
                        }
                }
        }
}
print "Press Enter to quit";
<STDIN>;COPY

TOP

本帖最后由 --Perl 于 2014-10-13 17:35 编辑

回复 1# 523066680
$&COPY
\$&COPY
:smile:

TOP

返回列表