MDA/MDD/TDD/DDD/DDDDDDD
posts - 536, comments - 111, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

用几句ruby代码刷人气(转)

Posted on 2008-04-05 13:04 leekiang 阅读(264) 评论(0)  编辑  收藏 所属分类: ruby
require  ' net/http '

count 
=   1 .. 100000    #  define an array

count.each{      
#  each 
| index |               #  element is index  1 2 3 4 5 6
printf  " #{index}  "   # print index and space
=  Net::HTTP.new( ' space.cnblogs.com ' , 80 #  create a object
resp, data  =  h.get( ' /group/topic/1605/ ' ,nil)  #  get 
if  resp.code  !=   " 200 "   #  if http response status code not is 200 
  puts resp.code     # put status code
  puts resp.message  # put status message
  
  resp.each{    
# put headers
   | key, val |
  puts 
" #{key}\t\t\t#{val} "
  }
  
  p data    
# put html
   break   #  break the eache
end
# sleep(1) #sleep  use second do inteval
}

来源:http://www.cnblogs.com/coderlee/archive/2008/03/25/1121652.html

只有注册用户登录后才能发表评论。


网站导航: