Class: WebReptile::Core

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, opts = {}) ⇒ Core

Returns a new instance of Core.



11
12
13
14
15
16
17
# File 'lib/web_reptile.rb', line 11

def initialize(url, opts = {})
  @url = url.is_a?(URI) ? url : URI(url)
  @opts = opts

  agent = Mechanize.new
  @page = agent.get(@url)
end

Class Method Details

.url(url, opts = {}) ⇒ Object



19
20
21
22
23
24
# File 'lib/web_reptile.rb', line 19

def self.url(url, opts = {})
  self.new(url, opts) do |web|
    yield web if block_given?
    self
  end
end

Instance Method Details

#grab(selector) ⇒ Object



26
27
28
# File 'lib/web_reptile.rb', line 26

def grab(selector)
   items = @page.search(selector)
end