以下の内容はhttps://kiririmode.hatenablog.jp/entry/20100916/p1より取得しました。


使ってみたかったモジュール使ってみた

明日からはもう定時で帰るんだ。

use strict;
use warnings;
use feature 'switch';

use URI;
use Try::Tiny;
use Log::Log4perl;
use Web::Scraper;
use YAML::Any;
use Config::Any;

my $VERSION = '0.01';

my $cfgfile = 'conf/fetch.yaml';
my $logger;

my $ranking = try {
    Log::Log4perl->init("conf/log4j.conf");
    $logger = Log::Log4perl->get_logger( 'My::Fetch' );
    $logger->info("start fetching ranking data");

    my $conf = Config::Any->load_files({
        files           => [$cfgfile], 
        use_ext         => 1,
        flatten_to_hash => 1,
    });

    $logger->info("retrieve from $conf->{$cfgfile}->{url}");

    my $scraper = scraper {
        process '//tr[@class="tbg1" or @class="tbg2"]',
            'records[]' => scraper {
                process '//th',        'rank'   => 'TEXT';
                process '//td[1]',     'status' => 'TEXT';
                process '//td[2]',     'title'  => 'TEXT';
                process '//td[3]',     'artist' => 'TEXT';
            };
        result 'records';
    };
    $scraper->user_agent->agent("My::Fetch/$VERSION");
    $scraper->scrape( URI->new( $conf->{$cfgfile}->{url} ) );
} catch {
    when (/Cannot open config file/) { print; exit 1; };               # handles Log4perl error 
    when (/GET .* failed: /)         { $logger->error($_); exit 2; };  # handles Web::Scraper error
    default { 
        $logger->error( $_ );
    };
} finally {
    $logger->info("complete") if $logger;
};



以上の内容はhttps://kiririmode.hatenablog.jp/entry/20100916/p1より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14