Created
October 22, 2016 12:11
-
-
Save DJNgoma/2778d3e9e5b90ba5d69c3f12ec6006c5 to your computer and use it in GitHub Desktop.
CollectAndSortInstagramFollowers
This file contains 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
require 'httparty' | |
txt = open("instagram.txt") | |
users = txt.read.split("\n") | |
usersHash = {} | |
users.each { |u| | |
url = "https://www.instagram.com/#{u}/?__a=1" | |
response = HTTParty.get(url) | |
userInfo = response.parsed_response | |
count = userInfo["user"]["followed_by"]["count"] | |
usersHash["#{u}"] = count | |
} | |
sortedUserHash = usersHash.sort_by{|k,v| v}.reverse | |
target = open("followerData.txt", 'w') | |
sortedUserHash.each {|u| | |
target.write(u) | |
target.write("\n") | |
} | |
target.close | |
print "Finally Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment