Class: Rextract::Spider

Inherits:
Object
  • Object
show all
Defined in:
lib/rextract/spider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Spider

Returns a new instance of Spider.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rextract/spider.rb', line 5

def initialize(opts = {})
  @agent = Rextract::Browser.new do |a|
    a.user_agent_alias    = opts[:user_agent_alias] || 'Mac Safari'
    a.follow_meta_refresh = true
    a.auth(opts[:user], opts[:password]) if opts.has_key?(:user) && opts.has_key?(:password)
    opts.each do |key, val|
      method = "#{key}="
      a.send(method, val) if a.respond_to?(method)
    end
  end
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



4
5
6
# File 'lib/rextract/spider.rb', line 4

def agent
  @agent
end