用几句ruby代码刷人气(转)
<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
h = 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
}
页:
[1]