0.0
No release in over 3 years
Ruby library for scraping performance information from CoRich Stage (stage.corich.jp). Supports searching listings and fetching detailed show data with built-in rate limiting.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 5.0
~> 13.0
~> 3.0

Runtime

~> 1.16
 Project Readme

corich_stage

CoRich舞台芸術から公演情報をスクレイピングするRuby gem。

インストール

gem "corich_stage"

使い方

公演一覧の取得

# 東京の公演一覧(デフォルト: 90日先まで)
summaries = CorichStage.search

# 基準日を指定(デフォルト: 今日)
summaries = CorichStage.search(date: Date.new(2026, 4, 1))

# 日付範囲を変更
summaries = CorichStage.search(days_ahead: 30)

# 組み合わせ: 4月1日から30日先まで
summaries = CorichStage.search(date: Date.new(2026, 4, 1), days_ahead: 30)

# ページ数制限
summaries = CorichStage.search(max_pages: 3)

summary = summaries.first
summary.stage_id    #=> "431567"
summary.title       #=> "闇に咲く花"
summary.venue       #=> "紀伊國屋サザンシアター TAKASHIMAYA"
summary.period      #=> "2026/03/28 (土) ~ 2026/04/19 (日)"
summary.start_date  #=> #<Date: 2026-03-28>
summary.end_date    #=> #<Date: 2026-04-19>

公演詳細の取得

stage = CorichStage.fetch("431567")

stage.title            #=> "闇に咲く花"
stage.company          #=> "こまつ座"
stage.director_name    #=> "大河内直子"
stage.playwright_name  #=> "井上ひさし"
stage.venue            #=> "紀伊國屋サザンシアター TAKASHIMAYA"
stage.period           #=> "2026/03/28 (土) ~ 2026/04/19 (日)"
stage.prices           #=> "3,000円 ~ 9,500円"
stage.duration         #=> "約3時間0分(休憩含む)を予定"
stage.cast             #=> "筧利夫、諏訪珠理、佐藤正宏、..."
stage.description      #=> "昭和20年、東京の下町..."
stage.staff            #=> "作・演出・音楽:糸井幸之介..."
stage.official_site    #=> "https://komatsuza.co.jp/..."

ヘルパーメソッド

stage.duration_minutes #=> 180        "約3時間0分" → 整数
stage.cast_members     #=> ["筧利夫", "諏訪珠理", ...]  読点区切り → 配列
stage.min_price        #=> 3000       "3,000円 ~ 9,500円" → 最小値
stage.max_price        #=> 9500       "3,000円 ~ 9,500円" → 最大値

設定

# config/initializers/corich_stage.rb
CorichStage.configure do |config|
  config.user_agent = "MyApp/1.0 (+https://example.com)"
  config.request_interval = 2.0  # リクエスト間隔(秒)
  config.timeout = 30            # タイムアウト(秒)
  config.max_retries = 3         # リトライ回数
end

Rails環境では CorichStage.loggerRails.logger が自動設定されます。

Rails連携の例

# app/jobs/fetch_stages_job.rb
class FetchStagesJob < ApplicationJob
  queue_as :default
  limits_concurrency to: 1, key: "corich_fetch"

  def perform
    summaries = CorichStage.search(max_pages: 10)
    summaries.each do |summary|
      next if Performance.exists?(corich_id: summary.stage_id)
      FetchStageDetailJob.perform_later(summary.stage_id)
    end
  end
end

注意事項

  • 本gemは CoRich舞台芸術 の公式APIではなく、Webスクレイピングにより情報を取得します
  • サイトへの過度なアクセスを避けるため、request_interval を適切に設定してください(デフォルト: 1秒)
  • サイトの構造変更により動作しなくなる場合があります
  • サイト運営者から要請があった場合は利用を停止してください

依存

  • Ruby >= 3.2
  • Nokogiri
  • net-http

ライセンス

MIT