0
我寫了這個腳本來基本解析URL的文本文件並返回http響應代碼,但我無法讓它工作。我能夠導入和解析文件,但無法獲取返回碼。提前致謝!紅寶石URL驗證
require 'net/http'
#Open URL from file
File.open("sample_input_file", "r") do |infile|
while (URI = infile.gets)
end
end
#Get HTTP response code
http = Net::HTTP.new
response = http.request_head(URI)
#Print result
if
response.code != "200"
puts URI + "Error"
else
puts "Ok"
end