Skip to content

naoyanickf/scrape_instagram_ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Scraping Instagram Ruby

Let's scrape instagram with Ruby! This is a short sample code to scrape instagram website with instagram user_id. You can get user profile and latest images.

##Code

require 'open-uri'
require 'JSON'

def scrape_instagram(user_id)
  begin
    instagram_source = open("https://www.instagram.com/#{user_id}").read
    content = JSON.parse(instagram_source.split("window._sharedData = ")[1].split(";</script>")[0])
    return content['entry_data']['ProfilePage'][0]['user']
  rescue Exception => e
    return nil
  end
end

##Usage

scrape_instagram("nyanchan22")

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages