Skip to content

Instantly share code, notes, and snippets.

@tai-cha
Last active March 16, 2019 17:39
Show Gist options
  • Save tai-cha/ee2f4c84dce1caaf75e5e218b086fcde to your computer and use it in GitHub Desktop.
Save tai-cha/ee2f4c84dce1caaf75e5e218b086fcde to your computer and use it in GitHub Desktop.
特定のツイートにいいねした人のTwitterのidを抽出するメソッド(戻り値は数値の配列)
def get_id_of_user_liked_tweet(tweet_id)
json_data = Net::HTTP.get(URI.parse('https://twitter.com/i/activity/favorited_popup?id=' + tweet_id))
found_ids = json_data.scan(/data-user-id=\\"+\d+/)
found_ids.each{|str| str.slice!(/data-user-id=\\\"+/)}
found_ids = found_ids.map(&:to_i)
unique_ids = found_ids.uniq
return unique_ids
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment