Class: SocialNet::Instagram::Api::ScrapeRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/social_net/instagram/api/scrape_request.rb

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ ScrapeRequest

Returns a new instance of ScrapeRequest.



11
12
13
14
15
16
# File 'lib/social_net/instagram/api/scrape_request.rb', line 11

def initialize(attrs = {})
  @host = 'www.instagram.com'
  @shortcode = attrs[:shortcode]
  @path = attrs.fetch :path, "/p/#{attrs[:shortcode]}/"
  @method = attrs.fetch :method, :get
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/social_net/instagram/api/scrape_request.rb', line 18

def run
  print "#{as_curl}\n"
  case response = run_http_request
  when Net::HTTPOK
    data_string = Nokogiri::HTML response.body
    parse_video_data data_string
  else
    raise Errors::ResponseError, response
  end
end