Last active
December 19, 2015 03:59
-
-
Save tsux89/5893769 to your computer and use it in GitHub Desktop.
status_id_collector.rb - Tweet.zipの「tweets.csv」からstatus_idのみを抽出します。「ruby status_id_collector.rb > tweet.txt」で使ったらいいかなと。Tweet_destroyer.rb - 同じディレクトリ内にある「tweet.txt」からstatus_idを読み取り、ツイートを消していくスクリプトです。正直な話、使いづらいと思う。なんか、いい削除してくれるサイトがあるので検索してみたほうがいいかも
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
require 'csv' | |
open("tweet.txt", "a"){|f| | |
CSV.foreach("tweets.csv"){|s| | |
f.write s | |
f.close | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# coding: utf-8 | |
require 'csv' | |
require 'pp' | |
open("tweet.txt", "a"){|f| | |
CSV.foreach("tweets.csv"){|s| | |
f.write s | |
f.close | |
} | |
} | |
require 'twitter' | |
ck = 'IQKbtAYlXLripLGPWd0HUA' | |
cs = 'GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU' | |
at = '' | |
ats = '' | |
# -------------AUTH TWITTER------------- # | |
$host = Twitter::Client.new( | |
:consumer_key => ck, | |
:consumer_secret => cs, | |
:oauth_token => at, | |
:oauth_token_secret => ats | |
) | |
open("tweet.txt"){|f| | |
f.each{|line| | |
begin | |
$host.status_destroy(line.chomp) | |
puts "Deleted: " + line | |
rescue Twitter::Error::ClientError | |
puts "skip: " + line + " (Twitter::Error::ClientError)" | |
line.chomp | |
rescue Twitter::Error::NotFound | |
puts "skip: " + line + " (Twitter::Error::NotFound)" | |
line.chomp | |
rescue URI::InvalidURIError | |
puts "skip: " + line + " (URI::InvalidURIError)" | |
line.chomp | |
rescue Twitter::Error::InternalServer | |
puts "skip: " + line + " (Twitter::Error::InternalServer)" | |
line.chomp | |
rescue Twitter::Error::ServiceUnavailable | |
puts "skip: " + line + " (Twitter::Error::ServiceUnavailable)" | |
line.chomp | |
rescue Twitter::Error::Unauthorized | |
puts "skip: " + line + " (Twitter::Error::Unauthorized)" | |
line.chomp | |
end | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment