Module: RubyInstagramScraper

Defined in:
lib/ruby-instagram-scraper.rb

Class Method Summary collapse

Class Method Details

.get_media(code) ⇒ Object



29
30
31
32
33
34
# File 'lib/ruby-instagram-scraper.rb', line 29

def self.get_media ( code )
  url = "https://www.instagram.com/p/#{ code }/?__a=1"
  params = ""

  JSON.parse( open( url + params ).read )["media"]
end

.get_tag_media_nodes(tag, max_id = nil) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/ruby-instagram-scraper.rb', line 21

def self.get_tag_media_nodes ( tag, max_id = nil )
  url = "https://www.instagram.com/explore/tags/#{ tag }/?__a=1"
  params = ""
  params = "&max_id=#{ max_id }" if max_id

  JSON.parse( open( url + params ).read )["tag"]["media"]["nodes"]
end

.get_user_media_nodes(username, max_id = nil) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/ruby-instagram-scraper.rb', line 13

def self.get_user_media_nodes ( username, max_id = nil )
  url = "https://www.instagram.com/#{ username }/?__a=1"
  params = ""
  params = "&max_id=#{ max_id }" if max_id

  JSON.parse( open( url + params ).read )["user"]["media"]["nodes"]
end

.search(query) ⇒ Object



6
7
8
9
10
11
# File 'lib/ruby-instagram-scraper.rb', line 6

def self.search ( query )
  url = "https://www.instagram.com/web/search/topsearch/"
  params = "?query=#{ query }"

  JSON.parse( open( url + params ).read )
end