我编写了这个脚本来基本上解析 URL 的文本文件并返回 http 响应代码,但是我无法让它工作。我能够导入和解析文件,但无法获取返回码。提前致谢!
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