Pregunta

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?

¿Fue útil?

Solución

The same result can be achieved by doing:

site = Faraday.new.get('http://www.mysite.com').body
nokogiri_object = Nokogiri::HTML(site)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top