Skip to content

Instantly share code, notes, and snippets.

@jaigouk
Created January 8, 2009 06:44
Show Gist options
  • Save jaigouk/44616 to your computer and use it in GitHub Desktop.
Save jaigouk/44616 to your computer and use it in GitHub Desktop.
require 'rubygems'
gem('twitter4r', '0.3.0')
require 'twitter'
require 'time'
require 'nokogiri'
require 'open-uri'
require "shorturl"
array = @wycat_merb_commits = []
@long_messages = []
merb = 'http://github.com/wycats/rails/commits/content_negotiation'
# Feed parsing
doc = Nokogiri::HTML(open(merb))
doc.css('div.human').each do |h|
h.search('div.message').each do |k| @message = k.content end
h.search('div.name').each do |k|
@name = (k.content).to_s.strip.gsub("(author)", "").gsub("(committer)","")
end
h.search('pre a[href]').each do |k|
@link = (k.attributes)
@new_link = ShortURL.shorten("http://github.com" + @link.to_s.strip.gsub("href", ''), :lns)
end
h.search('div.date').each do |k|
@date = k.content
@new_date = (Time.parse(@date.strip))
end
array <<{:message => @message, :name => @name, :date => @new_date, :link=>(@new_link) }
end
a = 0
array.each do |b|
a += 1
# puts Time.parse(b[:date].strip).month
# b[:name].each {|f| puts f}
end
puts a
## talk to twitter
#########################################################
#
# FOR POST TWITTER MESSAGES
#
#########################################################
#@post_client = Twitter::Client.new(:login => 'edgemerb', :password => '*******')
#genesis = 'Wed Jan 07 11:23:43 +0900 2009'
#@timeline = @post_client.timeline_for(:me, :since => genesis)
#array.each do |a|
# sleep(15)
# poster = String.new
# poster = a[:message] + a[:name] + a[:date] +a[:link]
# begin
# @timeline.each do |posted|
# if not (posted.text).include?(a[:message])
## status =@post_client.status(:post, poster)
## puts (posted.id).to_s + ' posted successfuly'
# puts posted.text
#
# else
## status =@post_client.status(:delete, posted.id)
# puts 'skip'
# end
# poster = nil
# end #timeline.each end
# rescue Twitter::RESTError => re
# unless re.code == "403"
# puts re
# end
# end #begin-rescue end
#end #array.each end
##########################################################
##
## FOR DELETE ALL TWITTER MESSAGES
#
#########################################################
@post_client = Twitter::Client.new(:login => 'edgemerb', :password => '********')
genesis = 'Wed Jan 07 11:23:43 +0900 2009'
@timeline = @post_client.timeline_for(:me, :since => genesis)
begin
@timeline.each do |posted|
status =@post_client.status(:delete, posted.id)
end #timeline.each end
rescue Twitter::RESTError => re
unless re.code == "403"
puts re
end
end #begin-rescue end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment