Skip to content

Instantly share code, notes, and snippets.

@dtan4
Last active December 18, 2015 14:39
Show Gist options
  • Save dtan4/5799224 to your computer and use it in GitHub Desktop.
Save dtan4/5799224 to your computer and use it in GitHub Desktop.
TSUTAYA のレンタル在庫情報を確認
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'open-uri'
require 'nokogiri'
URL_BASE = "http://store.tsutaya.co.jp/item/rental_cd"
def check_stock(product_id, store_id)
url = "#{URL_BASE}/#{product_id}.html?storeId=#{store_id}"
doc = Nokogiri::HTML.parse(open(url).read)
puts doc.search('span[@class=tolShStkInMrk]').text
end
if ARGV.length < 2
$stderr.puts "./tsutaya.rb [product_id] [store_id]"
exit 1
end
# DDRMAX 2 -Dance Dance Revolution 7thMIX- ORIGINAL SOUNDTRACK
# product_id: 001999963
# SHIBUYA TSUTAYA
# store_id: 2312
product_id = ARGV[0]
store_id = ARGV[1]
check_stock(product_id, store_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment