Show
Ignore:
Timestamp:
12/01/07 01:12:05 (14 months ago)
Author:
yasu
Message:

lang/perl/WWW-NicoVideo?:

個別エントリ (http://www.nicovideo.jp/watch/smXXXXXXX) のscraperを追加。
忘れないように今のうちにバージョン表記を0.04にしておく。
おなかすいた。

Location:
lang/perl/WWW-NicoVideo/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/WWW-NicoVideo/trunk/README

    r2028 r2189  
    1 WWW-NicoVideo version 0.03 
     1WWW-NicoVideo version 0.04 
    22========================== 
    33 
  • lang/perl/WWW-NicoVideo/trunk/lib/WWW/NicoVideo.pm

    r2147 r2189  
    1919__PACKAGE__->mk_accessors(qw[agent retry retryInterval mail passwd]); 
    2020 
    21 our $VERSION = "0.03"; 
     21our $VERSION = "0.04"; 
    2222our $AGENT_NAME = "@{[__PACKAGE__]}/$VERSION)"; 
    2323 
  • lang/perl/WWW-NicoVideo/trunk/lib/WWW/NicoVideo/Scraper.pm

    r2122 r2189  
    99use WWW::NicoVideo::URL; 
    1010use base qw[Web::Scraper]; 
    11  
     11use Time::Local; 
    1212sub import 
    1313{ 
     
    1717  no strict "refs"; 
    1818  *{"$pkg\::scraper_entries"} = \&scraper_entries; 
     19  *{"$pkg\::scraper_entry"} = \&scraper_entry; 
    1920  *{"$pkg\::scraper"} = \&scraper; 
    2021  *{"$pkg\::process"} = sub { goto &process }; 
     
    5152                      url => '@href'); 
    5253              process('/div/div[2]/p', 
    53                       desc => sub { shift->content_array_ref->[-1] =~ /\s*(.*)/; 
    54                                     $1 }), 
     54                      desc => sub { shift->as_trimmed_text }), 
    5555              process('/div/div[2]/div/p/strong', 
    5656                      comments => sub { my $x = shift->as_text; 
     
    6161} 
    6262 
     63sub scraper_entry() 
     64{ 
     65  scraper { 
     66    process('//h1', 
     67            title => 'TEXT'); 
     68    process('//div[@id="PAGEBODY"]/div/div/p/img', 
     69            imgUrl => '@src', 
     70            imgWidth => '@width', 
     71            imgHeight =>  '@height'); 
     72    my $postDateTimeStr; 
     73    process('//div[@id="PAGEBODY"]/div/div/p[2]/strong', 
     74            postDateTimeStr => sub { 
     75              $postDateTimeStr = shift->content_array_ref->[-1]; 
     76              $postDateTimeStr =~ tr/:/:/; 
     77              $postDateTimeStr }, 
     78            postDateTime => sub { 
     79              $postDateTimeStr =~ 
     80                /(\d+)年(\d+)月(\d+)日\s+(\d+)\D+(\d+)\D+(\d+)/; 
     81              timelocal($6, $5, $4, $3, $2, $1); } 
     82           ); 
     83    process('//div[@id="PAGEBODY"]/div/div/p[3]', 
     84            fullDesc => 'TEXT'); 
     85    process('//div[@id="PAGEBODY"]/div/div[2]/p', 
     86            tags => sub { [split /\xA0+/, shift->content_array_ref->[-1]] }); 
     87  }; 
     88 
     89} 
     90 
    6391"Ritsuko";