2007-10-20
■ [CustomFeed-Script] Web::Scraper for CF::Script コミックHOLIC

コミックHOLICの各話を取得。
assets/plugins/CustomFeed-Script/comicholic.pl
#!/usr/bin/perl use strict; use warnings; use utf8; use URI; use Web::Scraper; use YAML; my $url = 'http://www.toranoana.jp/webcomic/holic/'; my $s = scraper { process '//div[./a[@target="_blank"]]', 'comic[]' => scraper { process '/div/a', link => ['@href', sub { $_->as_string } ]; process '/div/a/img', icon => ['@src', sub { +{ url => $_->as_string } } ]; process '/div', title => 'text'; result qw/link icon title/; }; result qw/comic/; }; binmode STDOUT, ':utf8'; print YAML::Dump +{ title => 'コミックHOLIC', link => $url, entry => $s->scrape(URI->new($url)), };
config.yaml
plugins: - module: Subscription::Config config: feed: - url: 'script:/path/to/comicholic.pl' - module: CustomFeed::Script
■ [CustomFeed-Script] Web::Scraperを使ってFlexComixブラッドのassetsをYahoo!コミック無料マガジン全般対応版に書き直した

以前作った↑を,Web::Scraperを使ってYahoo!コミック無料マガジン全般対応版に書き直した。
assets/plugins/CustomFeed-Script/yahoocomic.pl
#!/usr/bin/perl use strict; use warnings; use utf8; use URI; use Web::Scraper; use YAML; my $mag = shift; $mag = "http://comics.yahoo.co.jp/magazine/${mag}_0001.html" unless $mag =~ m!^http://!; my $s = scraper { process '//table[@cellspacing="4"][1]//b', title => 'text'; process '//table[@cellpadding="4" and .//img and count(.//tr)=4]', 'comic[]' => scraper { process '//tr[1]//img', icon => ['@src', sub { +{ url => $_->as_string } } ]; process '//tr[2]//a', link => ['@href', sub { $_->as_string } ]; process '//tr[2]//a/b', title => 'text'; process '//tr[3]//small', author => ['text', sub { (/:(.*?)\s*$/)[0] } ]; process '//tr[4]//small', body => 'text'; result qw/icon link title author body/; }; result qw/title comic/; }; my $res = $s->scrape(URI->new($mag)); binmode STDOUT, ':utf8'; print YAML::Dump +{ title => $res->{title}, link => $mag, entry => $res->{comic}, };
config.yaml
plugins: - module: Subscription::Config config: feed: - url: 'script:/path/to/yahoocomic.pl blood' - url: 'script:/path/to/yahoocomic.pl flare' - url: 'script:/path/to/yahoocomic.pl weeklyyj' - url: 'script:/path/to/yahoocomic.pl fang' - url: 'script:/path/to/yahoocomic.pl gumbo' - url: 'script:/path/to/yahoocomic.pl marjong' - url: 'script:/path/to/yahoocomic.pl sangokushi' - url: 'script:/path/to/yahoocomic.pl essay' - module: CustomFeed::Script - module: SmartFeed::All config: title: Yahoo!コミック > 無料マガジン link: http://comics.yahoo.co.jp/magazine/
コメント
トラックバック - http://plagger.g.hatena.ne.jp/SweetPotato/20071020