Module: RubyInstagramScraper

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

Class Method Summary collapse

Class Method Details

.get_media(code) ⇒ Object



39
40
41
42
43
44
# File 'lib/ruby-instagram-scraper.rb', line 39

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



31
32
33
34
35
36
37
# File 'lib/ruby-instagram-scraper.rb', line 31

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(username, max_id) ⇒ Object



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

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

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

.get_user_media_nodes(username, max_id = nil) ⇒ Object



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

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
12
13
# File 'lib/ruby-instagram-scraper.rb', line 6

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

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