0

Rubyで次のようなことができるようにしたいと思います。

(new[]{"http://google.com", "http://facebook.com", "http://microsoft.com", "http://twitter.com", "http://stackoverflow.com"})
.AsParallel()
.Select(q => WebRequest.Create(q).GetResponse())

これはまた、要素の順序を維持し、遅延実行を使用する必要があります。利用できるオプションはありますか?

4

1 に答える 1

1

ライブラリのラッパーであるRubycurbgemには、複数のURLを並行curlてフェッチできる「マルチ」モードがあります。

例から:

# Make multiple GET requests
easy_options = { :follow_location => true }
multi_options = { :pipeline => true }

Curl::Multi.get('url1','url2','url3','url4','url5', easy_options, multi_options) do |easy|
  # do something interesting with the easy response
  puts easy.last_effective_url
end
于 2012-10-15T16:00:21.987 に答える