noboruhiの日記

2007-06-20

[][]さくら水産日替わり定食献立表を取得する 22:41

需要があったので書いてみました。

※7/8更新 日付に全角数字が含まれる場合に対応

assets/plugins/CustomFeed-Script/sakura.pl

#!/usr/bin/perl -w
use strict;
#use URI;
use HTTP::Cookies;
use LWP::UserAgent;
use HTTP::Request::Common qw (POST);
use YAML::Syck;
use Web::Scraper;
use utf8;
use DateTime::Format::Japanese;
use Encode;

my $uri = URI->new("http://www.teraken.co.jp/menu/lunchmenu/index.html");

my $s = scraper {
    process "table tr",
       "list[]" => scraper {
       process 'div[align="right"]',
           "date" => 'TEXT';
       process 'div[align="left"]',
           "text" => 'TEXT';
       result 'date','text';
    };
    result 'list';
};

my $scr = $s->scrape($uri);
#my $scr = $item->scrape($content);

my $feed = {
    title => "sakura suisan",
    link  => $uri->as_string,
};


for my $menu (@{ $scr}) {
    if ($menu->{date} =~ m/.*(\d+)(\d+)(.)曜日/ ) {
        my $month = $1;
        my $day   = $2;
        $month =~ tr/0-9/0-9/;
        $day   =~ tr/0-9/0-9/;
        my $date  = "2007-$month-$day";
        push @{$feed->{entries}}, {
            title => $menu->{text},
            date  => $date,
            #date  => $menu->{date},
        };
    }
}


print Dump($feed);

使用例。

sakuranch.yaml


global:
  plugin_path:
    - lib/Plagger/Plugin
  assets_path: assets
  timezone: Asia/Tokyo
  log:
    level: info

plugins:
  - module: CustomFeed::Script
  - module: Subscription::Config
    config:
      feed:
        - script:assets/plugins/CustomFeed-Script/sakura.pl

  - module: Aggregator::Simple


  - module: Publish::iCal
    config:
      dir: .
      filename: sakuranch.ics

ChampChamp 2011/11/24 18:28 Umm, are you really just gvinig this info out for nothing?

xpnosvwbcxpnosvwbc 2011/11/28 22:11 NXBeNP , [url=http://sbwckdiuibzc.com/]sbwckdiuibzc[/url], [link=http://noxsnoymfdfw.com/]noxsnoymfdfw[/link], http://mwphegoqmyyh.com/

llgynfedztpllgynfedztp 2011/12/01 17:21 ZOwEAO <a href="http://aoiqjphicmak.com/">aoiqjphicmak</a>

mvywaxbznkkmvywaxbznkk 2011/12/06 00:09 Tjmh7a , [url=http://igfizfiefnjb.com/]igfizfiefnjb[/url], [link=http://bgygbfwyktpf.com/]bgygbfwyktpf[/link], http://ncvauuxamkwg.com/

ゲスト