Class: Parser

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

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Parser

Returns a new instance of Parser.



4
5
6
# File 'lib/tagfinder/parser.rb', line 4

def initialize(url)
	@url = url
end

Instance Method Details

#find_text_in_document(text) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/tagfinder/parser.rb', line 8

def find_text_in_document(text)
	agent = Mechanize.new
	page = agent.get(@url)
	result = page.search(":contains('#{text}'):not(:has(:contains('#{text}')))")
	if !result.to_s.empty?
		return result
	end
	return nil
end