Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72936
  • 博文数量: 13
  • 博客积分: 1435
  • 博客等级: 上尉
  • 技术积分: 220
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-22 10:41
文章分类
文章存档

2010年(2)

2009年(11)

我的朋友

分类:

2009-08-04 07:20:16

[学习perl 练手用,请勿用于商业用途,尊重别人的劳动成果,访问一下提供资料的网站,最好看一下它的广告]
取得电子节目单

#!/usr/bin/perl

use strict;
use warnings;
use LWP;
use LWP::UserAgent;
use LWP::Simple;
use HTML::Tree;
use URI::Escape;
use URI::QueryParam;
use URI;
use Time::localtime;
use Time::Local;

my $root = '';
my $from;
my $to;
my $curdate;
my $querydate;
my $uri = URI->new('http:///newpage/dabenying/jmb.asp');
my $localfile;
my $locdir ;
my $tm;
my $tvid ;

$from = timelocal( 0, 0, 0, 5, 7, 2009 - 1900 );
$to = timelocal( 0, 0, 0, 10, 7, 2009 - 1900 );

mkdir($root);
for ( $tvid = 1 ; $tvid <= 7 ; $tvid++ )
{
    $locdir = sprintf("%s/%d",$root,$tvid);
    mkdir($locdir);
    $curdate = $from;
    while ( $curdate le $to )
    {
        $tm = localtime($curdate);
        $querydate = sprintf("?ChannelID=%d&jmbDate=%04d-%02d-%02d",$tvid,$tm->year +1900,$tm->mon+1,$tm->mday);
        $localfile = sprintf("%s/%04d%02d%02d.html",$locdir, $tm->year +1900,$tm->mon+1,$tm->mday);
        $uri->query($querydate);
     print $uri->as_string,"\n";
     print $localfile,"\n";
        
        getstore($uri->as_string, $localfile);
                
        $curdate += 24 * 3600;

    }
}



阅读(821) | 评论(0) | 转发(0) |
0

上一篇:perl学习: EPG之BTV

下一篇:perl学习: EPG之AHTV

给主人留下些什么吧!~~