Method: Mechanize::Page#parser

Defined in:
lib/mechanize/page.rb,
lib/mechanize/page.rb,
lib/mechanize/page.rb

#parserObject Also known as: root

:method: at

Search through the page for path under namespace using Nokogiri’s #at. The path may be either a CSS or XPath expression.

See also Nokogiri::XML::Node#at



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/mechanize/page.rb', line 200

def parser
  return @parser if @parser
  return nil unless @body

  if @encoding then
    @parser = @mech.html_parser.parse html_body, nil, @encoding
  elsif mech.force_default_encoding then
    @parser = @mech.html_parser.parse html_body, nil, @mech.default_encoding
  else
    @encodings.reverse_each do |encoding|
      @parser = @mech.html_parser.parse html_body, nil, encoding

      break unless encoding_error? @parser
    end
  end

  @parser
end