我写了以下代码:
require 'net/http'
require 'uri'
require 'IPAddr'
require 'timeout'
require 'Resolv'
require 'open-uri'
#puts "Origin IP:\n\n"
#originip = gets()
(IPAddr.new("209.85.175.120")..IPAddr.new("209.85.175.150")).each do |address|
uri = URI("http://#{address.to_s}")
puts "#{uri}"
http = Net::HTTP.new(uri.host, uri.port)
puts "#{http}"
Net::HTTP.start(uri.host, uri.port) do |http|
request = Net::HTTP::Get.new uri.request_uri
response = http.request request
if response.code == "301" || response.code == "400" then
end
#request.initialize_http_header({"Origin" => "#{originip}"})
end
uri = URI("http://#{address.to_s}")
我的if
情况可以去排队吗
if response.code == "301" || response.code == "400" then
# condition
end
在上面的代码中变成真的了吗?如果我的条件为真,如何转到下一个 IP 地址并跳过当前地址?
是否可以在 Ruby 中执行类似标签和goto
语句的操作?