获取页面:
require 'net/http'
pages =%w(www.baidu.com www.163.com www.qq.com www.oschina.net bbs.chinaunix.net)
threads=[]
for page_to_fetch in pages
threads << Thread.new(page_to_fetch) do |url|
h=Net::HTTP.new(url, 80)
puts "Fetching: #{url}"
resp = h.get('/')
puts "Got #{url}: #{resp.message}"
end
end
threads.each {
|thr| thr.join
}
1219

被折叠的 条评论
为什么被折叠?



