Skip to content

Instantly share code, notes, and snippets.

@DJNgoma
Created October 22, 2016 12:11
Show Gist options
  • Save DJNgoma/2778d3e9e5b90ba5d69c3f12ec6006c5 to your computer and use it in GitHub Desktop.
Save DJNgoma/2778d3e9e5b90ba5d69c3f12ec6006c5 to your computer and use it in GitHub Desktop.
CollectAndSortInstagramFollowers
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