=begin # club_ntdo_reserve クラブニンテンドーから予約ボーナス対象タイトルを取得する。 ## ダウンロード http://bmky.net/product/pragger/#club_ntdo_reserve ## 解説 予約可能な全てのタイトルを取得して、日付に予約開始日を設定したアイテムを返す。 ## 使い方 - module: myplugin::club_ntdo_enquete config: authfile: config/club_ntdo_auth.yaml # ログインに使用する設定ファイル ## 設定ファイルの書き方 --- userid: xxxxxxxxx passwd: xxxxxxxxx ## 更新履歴 2008/10/02 : サイトリニューアルに対応 2008/05/31 : サイトリニューアルに対応 2008/03/03 : リリース =end require 'rubygems' require 'mechanize' require "time" def club_ntdo_reserve( config, data ) auth = YAML.load( File.read( config['authfile'] ) ) clubntd_url = "http://club.nintendo.jp/member/exec/index" agent = WWW::Mechanize.new page = agent.get( clubntd_url ) form = page.forms[0] form.fields.find { |f| f.name == "userid" }.value = auth["userid"] form.fields.find { |f| f.name == "passwd" }.value = auth["passwd"] page = agent.submit( form ) html = agent.get_file( "https://club.nintendo.jp/member/exec/reserveList" ).toutf8 html.gsub!( /\r$/m, "" ) open("test.html","w"){|w| w.puts html } items = [] html.gsub( /
(.*?)<\/p>/ )[0][0] limit_html = match.scan( /予約登録期間<\/td>(.*?)<\/tr>/m )[0][0] limit = limit_html.gsub( /\s| |日|<\/?td>/, "" ).gsub( /年|月/, "/" ) date_begin = limit.split( /~|〜/ )[0] date_end = limit.split( /~|〜/ )[1] item = "" item.instance_eval do @link = clubntd_url def link @link end @title = [ "[予約ボーナス]", title, limit ].join( " " ).gsub( /〜/, "~" ) def title @title end @date = Time.parse( date_begin ) def date @date end end items << item if Time.now > item.date end return items end