Skip to content

Instantly share code, notes, and snippets.

@kkosuge
Last active May 24, 2016 04:06
Show Gist options
  • Save kkosuge/5a7df9dc4b8cddf3608d to your computer and use it in GitHub Desktop.
Save kkosuge/5a7df9dc4b8cddf3608d to your computer and use it in GitHub Desktop.
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = "YOUR_CONSUMER_KEY"
config.consumer_secret = "YOUR_CONSUMER_SECRET"
config.access_token = "YOUR_ACCESS_TOKEN"
config.access_token_secret = "YOUR_ACCESS_SECRET"
end
print "screen_name: "
target = gets.chomp
print "爆撃数(MAX 3200): "
count = gets.chomp.to_i
tweets = []
(count / 200 + 1).times do |i|
c = count-i*200 > 200 ? 200 : count-i*200
begin
tweets << client.user_timeline(target, count: c , page: i+1)
rescue => e
puts e
next
end
end
tweets.each_with_index do |t,i|
t.each_with_index do |tweet,index|
puts "#{i*200 + index + 1}: #{tweet.text}"
Thread.new do
begin
client.favorite_create(tweet.id)
puts "done!"
rescue => e
puts e
end
end
end
end
Thread::list.each {|t| t.join if t != Thread::current}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment