Show
Ignore:
Timestamp:
11/24/07 08:41:59 (7 years ago)
Author:
tokuhirom
Message:

CommentGetter: jugem is now in the siteinfo.

Location:
lang/perl/WWW-CommentGetter/trunk/WWW-CommentGetter/lib/WWW/CommentGetter
Files:
1 removed
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/WWW-CommentGetter/trunk/WWW-CommentGetter/lib/WWW/CommentGetter/Plugin.pm

    r1938 r1949  
    2727    return unless $url =~ $siteinfo->{url}; 
    2828 
    29     my $ua = LWP::UserAgent->new; 
     29    my $ua = LWP::UserAgent->new(agent => __PACKAGE__); 
    3030    my $res = $ua->get($url); 
    3131    unless ($res->is_success) { 
     
    4343        my $s = {}; 
    4444        while (my ($key, $local_xpath) = each %{$siteinfo->{attributes}}) { 
     45            warn "get $key by $local_xpath" if $ENV{DEBUG}; 
    4546            my $xpath = join '', $siteinfo->{context}, "[$cnt]", $local_xpath; 
    4647            $s->{$key} = as_text($tree->findnodes($xpath)->[0]); 
     
    6061 
    6162    if ($element->isTextNode) { 
    62         trim $element->string_value; 
     63        trim($element->string_value); 
    6364    } else { 
    64         trim $element->as_text; 
     65        trim($element->as_text); 
    6566    } 
    6667} 
     
    7374} 
    7475 
    75  
    76761; 
  • lang/perl/WWW-CommentGetter/trunk/WWW-CommentGetter/lib/WWW/CommentGetter/Plugin/SiteInfo.pm

    r1938 r1949  
    6464            author => '//span[@class="comment_author"]', 
    6565        }, 
     66    }, 
     67    { 
     68        url        => '^http://.*.jugem.jp/.*', 
     69        context    => '//dt[@class="com_desc"]', 
     70        attributes => { 
     71            body   => '/text()', 
     72            author => '/following-sibling::dd[1]/ul/li[1]', 
     73            date   => '/following-sibling::dd[1]/ul/li[2]', 
     74        }, 
    6675    } 
    6776];