Class: SocialNet::Facebook::Api::ScrapeRequest

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

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ ScrapeRequest

Returns a new instance of ScrapeRequest.



12
13
14
15
16
17
18
# File 'lib/social_net/facebook/api/scrape_request.rb', line 12

def initialize(attrs = {})
  @host = 'www.facebook.com'
  @username = attrs[:username]
  @video_id = attrs[:video_id]
  @path = attrs.fetch :path, "/#{attrs[:username]}/videos/#{attrs[:video_id]}/"
  @method = attrs.fetch :method, :get
end

Instance Method Details

#runObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/social_net/facebook/api/scrape_request.rb', line 20

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