1

I have considered switching from Mechanize to Faraday, since I am making a lot of requests and it seems to be a lot quicker. What I couldn't find out, however, is if it is possible to parse the response body as an Nokogiri Object. The Mechanize way to do so is as follows:

Mechanize.new.get(url).parser

How can that be achieved using Faraday instead of Mechanize?

Severin
  • 8,508
  • 14
  • 68
  • 117
  • did you tried open-uri? first of all `require 'nokogiri'` and `require 'open-uri'`. And then `noko_obj = Nokogiri::HTML(open(url)) ` – rony36 Jan 30 '14 at 07:11
  • It's not necessary to use `require 'nokogiri'`. Mechanize does it automatically, since it uses Nokogiri internally. – the Tin Man Feb 12 '14 at 05:17

1 Answers1

2

The same result can be achieved by doing:

site = Faraday.new.get('http://www.mysite.com').body
nokogiri_object = Nokogiri::HTML(site)
Severin
  • 8,508
  • 14
  • 68
  • 117