How to receive several channels at the same time

I'm new to rubies on rails, and I just started looking at the rails, throwing textbooks.

To parse the feeds, I started using the zirra tuple.

To receive multiple feeds at once, the feedzirra function has this function.

feed_urls = ["http://feeds.feedburner.com/PaulDixExplainsNothing",
"http://feeds.feedburner.com/trottercashion"]
feeds = Feedzirra::Feed.fetch_and_parse(feed_urls)

If I have 100 channels, this procedure takes some time to index the 100th channel, so

How to parse all of these files, can we say that 100 channels at a time?

Waiting for your help and support

+3
source share
1 answer

Feedzirra Typhoeus , :

#!/usr/bin/env ruby
require 'rubygems'
require 'typhoeus'
require 'feedzirra'

feed_urls = ["http://feeds.feedburner.com/PaulDixExplainsNothing", "http://feeds.feedburner.com/trottercashion"]

hydra = Typhoeus::Hydra.new
feeds = {}

feed_urls.each do |feed|
        r = Typhoeus::Request.new(feed)
        r.on_complete do |response|
                feeds[r.url] = Feedzirra::Feed.parse(response.body)
        end
        hydra.queue r
end
hydra.run
puts feeds.inspect

, , . - , .

+6

Source: https://habr.com/ru/post/1762491/


All Articles