lib/html2rss/item.rb in html2rss-0.2.1 vs lib/html2rss/item.rb in html2rss-0.2.2

- old
+ new

@@ -1,6 +1,7 @@ require 'faraday' +require 'faraday_middleware' require 'open-uri' require 'nokogiri' require_relative 'item_extractor' require_relative 'attribute_post_processors' @@ -45,10 +46,14 @@ def categories config.categories.map(&method(:method_missing)).uniq.keep_if { |category| category.to_s != '' } end def self.from_url(url, config) - connection = Faraday.new(url: url, headers: config.headers) + connection = Faraday.new(url: url, headers: config.headers) { |faraday| + faraday.use FaradayMiddleware::FollowRedirects + faraday.adapter Faraday.default_adapter + } + page = Nokogiri::HTML(connection.get.body) page.css(config.selector('items')).map do |xml_item| new xml_item, config end end