Last active
March 16, 2019 17:39
-
-
Save tai-cha/ee2f4c84dce1caaf75e5e218b086fcde to your computer and use it in GitHub Desktop.
特定のツイートにいいねした人のTwitterの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
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