我写出这个脚本基本上解析了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
答案 0 :(得分:2)