Domanda

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?

È stato utile?

Soluzione

The same result can be achieved by doing:

site = Faraday.new.get('http://www.mysite.com').body
nokogiri_object = Nokogiri::HTML(site)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top