六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 121|回复: 0

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

[复制链接]

升级  90.33%

149

主题

149

主题

149

主题

举人

Rank: 3Rank: 3

积分
471
 楼主| 发表于 2013-2-7 20:20:52 | 显示全部楼层 |阅读模式
<div style="border: 1px solid rgb(204, 204, 204); padding: 4px 5px 4px 4px; background-color: rgb(238, 238, 238); font-size: 13px; width: 98%;"><!---->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
}
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表