سؤال

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?

هل كانت مفيدة؟

المحلول

The same result can be achieved by doing:

site = Faraday.new.get('http://www.mysite.com').body
nokogiri_object = Nokogiri::HTML(site)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top