Method: Html2rss::Item.from_url
- Defined in:
- lib/html2rss/item.rb
.from_url(url, config) ⇒ Array<Html2rss::Item>
Fetches items from a given URL using configuration settings.
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/html2rss/item.rb', line 25 def self.from_url(url, config) ctx = RequestService::Context.new(url:, headers: config.headers) body = RequestService.execute(ctx, strategy: config.strategy).body body = ObjectToXmlConverter.new(JSON.parse(body)).call if config.json? Nokogiri.HTML(body) .css(config.selector_string(Config::Selectors::ITEMS_SELECTOR_NAME)) .map { |xml| new(xml, config) } .select(&:valid?) end |