Skip to content

Instantly share code, notes, and snippets.

@smokeymonkey
Created June 21, 2011 05:10
Show Gist options
  • Save smokeymonkey/1037285 to your computer and use it in GitHub Desktop.
Save smokeymonkey/1037285 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby -Ku
require 'rubygems'
require 'oauth'
require 'rubytter'
require 'open-uri'
require 'nokogiri'
#require 'rexml/document'
$KCODE = "UTF8"
# 設定ファイルをロードする
# OAuth用の以下4つの変数を定義
# CONSUMER_KEY
# CONSUMER_SECRET
# ACCESS_TOKEN
# ACCESS_SECRET
load "#{ENV['HOME']}/smokeymonkey.oauth"
begin
diarylist = Array.new
doc = Nokogiri::HTML(open('http://www.joyfit.jp/diary/index.php?shop_no=7'))
doc.xpath('//div[@class="diary_box"]/div[@class="diary_head"]').each do |x|
tdate = x.search('p[@class="diary_date"]').text
tstaff = x.search('p[@class="diary_staff"]').text.gsub(/STAFF:/,"")
tti = x.search('h3[@class="diary_ti"]').text
diary = "【JOYFIT平岡公園スタッフダイアリー】[" + tdate + "] " + tti + " by " + tstaff + " http://www.joyfit.jp/diary/index.php?shop_no=7"
diarylist << diary
end
consumer = OAuth::Consumer.new(
CONSUMER_KEY,
CONSUMER_SECRET,
:site => 'http://api.twitter.com'
)
token = OAuth::AccessToken.new(
consumer,
ACCESS_TOKEN,
ACCESS_SECRET
)
client = OAuthRubytter.new(token)
client.update(diarylist.shift)
rescue
print "RuntimeError: ", $!, "\n";
end
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment