Created
August 27, 2015 18:33
-
-
Save renatodex/969718690296e740f82f to your computer and use it in GitHub Desktop.
A Script to extract all followers using the Instagram API
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 'open-uri' | |
require 'json' | |
require 'typhoeus' | |
def generate_resultset(url) | |
output = [] | |
result = JSON.parse(Typhoeus.get(url).body) | |
output += result['data'].inject([]) do |arr,d| | |
arr << d['username'] | |
arr | |
end | |
puts "Fetching API Url #{url}" | |
if !result['pagination'].empty? | |
output += generate_resultset(result['pagination']['next_url']) | |
else | |
output | |
end | |
end | |
# This is where you insert your first image (then it will loop indefinitivelly until the end of universe) | |
start_url = "https://api.instagram.com/v1/users/416240579/followed-by?access_token=416240579.xxxxx" | |
output = generate_resultset(start_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment