Class: SocialNet::Facebook::Api::ScrapeRequest
- Inherits:
-
Object
- Object
- SocialNet::Facebook::Api::ScrapeRequest
- Defined in:
- lib/social_net/facebook/api/scrape_request.rb
Instance Method Summary collapse
-
#initialize(attrs = {}) ⇒ ScrapeRequest
constructor
A new instance of ScrapeRequest.
- #run ⇒ Object
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
#run ⇒ Object
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 |