Class: JobsCrawler::Robots::Base
- Inherits:
-
Object
- Object
- JobsCrawler::Robots::Base
show all
- Defined in:
- lib/jobs_crawler/robots/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(url) ⇒ Base
Returns a new instance of Base.
5
6
7
8
|
# File 'lib/jobs_crawler/robots/base.rb', line 5
def initialize(url)
@url = url
@engine = Mechanize.new
end
|
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
3
4
5
|
# File 'lib/jobs_crawler/robots/base.rb', line 3
def url
@url
end
|
Instance Method Details
#crawl ⇒ Object
10
11
12
13
|
# File 'lib/jobs_crawler/robots/base.rb', line 10
def crawl
set_html
to_json
end
|
15
16
17
|
# File 'lib/jobs_crawler/robots/base.rb', line 15
def (css_selector)
@html.css(css_selector).text
end
|
#set_html ⇒ Object
23
24
25
|
# File 'lib/jobs_crawler/robots/base.rb', line 23
def set_html
@html = Nokogiri::HTML(body)
end
|
#to_json ⇒ Object
19
20
21
|
# File 'lib/jobs_crawler/robots/base.rb', line 19
def to_json
raise NotImplemetedError, 'You need to provide a concrete implemetatioen'
end
|