Feedjira:你能解析多个网址吗?

时间:2018-05-14 04:09:28

标签: ruby-on-rails ruby parsing xml-parsing feedjira

编辑** 来自this post Jon提到他想要摆脱2.0中的并发性,而是在应用程序中传递单个url并处理并发性,工作人员可能是这种方法。 / em>的

我正在尝试使用FeedJira解析多个网址(使用farday gem),但收到参数错误。过去有没有人成功解析过多个网址? FeedJira :: Feed的The source表示它会返回单个Feed网址或Feed网址数组。

.fetch_and_parse(urls, options = {}) ⇒ Object

脚本

feed_urls = ["https://jobs.startupnorth.ca/jobs.rss", "https://jobs.startupnorth.ca/jobs.rss"]
feed = Feedjira::Feed.fetch_and_parse(feed_urls)

错误

ArgumentError: bad argument (expected URI object or URI string)
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday/utils.rb:277:in `URI'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday/connection.rb:315:in `url_prefix='
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday/connection.rb:80:in `initialize'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday.rb:70:in `new'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/faraday-0.15.0/lib/faraday.rb:70:in `new'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/feedjira-2.1.4/lib/feedjira/feed.rb:82:in `connection'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/feedjira-2.1.4/lib/feedjira/feed.rb:68:in `fetch_and_parse'
    from (irb):144
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/console.rb:65:in `start'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/console_helper.rb:9:in `start'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:78:in `console'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/railties-5.0.7/lib/rails/commands.rb:18:in `<top (required)>'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in `require'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in `block in require'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:293:in `require'
    from /Users/taylorcooney/code/startupjobstoronto/bin/rails:9:in `<top (required)>'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `load'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `block in load'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:259:in `load_dependency'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/activesupport-5.0.7/lib/active_support/dependencies.rb:287:in `load'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /Users/taylorcooney/.rbenv/versions/2.4.3/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from -e:1:in `<main>'

1 个答案:

答案 0 :(得分:1)

此方法在2.0.0版中已更改。确保您使用的是版本&lt; 2。