class SagroneScraper::Agent
Constants
- AGENT_ALIASES
- Error
Attributes
page[R]
url[R]
Public Class Methods
http_client()
click to toggle source
# File lib/sagrone_scraper/agent.rb, line 24 def self.http_client Mechanize.new do |agent| agent.user_agent_alias = AGENT_ALIASES.sample agent.max_history = 0 end end
new(options = {})
click to toggle source
# File lib/sagrone_scraper/agent.rb, line 11 def initialize(options = {}) @url = options.fetch(:url) do raise Error.new('Option "url" must be provided') end @page = http_client.get(url) rescue StandardError => error raise Error.new(error.message) end
Public Instance Methods
http_client()
click to toggle source
# File lib/sagrone_scraper/agent.rb, line 20 def http_client @http_client ||= self.class.http_client end