I;m to tierd to explain
This commit is contained in:
+32
-11
@@ -93,12 +93,32 @@ end
|
||||
repeat = 0
|
||||
working = 0
|
||||
notWorking = 0
|
||||
config = File.read("config.txt")
|
||||
exist = true
|
||||
|
||||
while repeat < ARGV.size
|
||||
if Valid.url? ARGV[repeat]
|
||||
begin
|
||||
config = File.read("config.txt")
|
||||
rescue File::NotFoundError
|
||||
puts "Oh No! It seems that your config.txt file does not exist!"
|
||||
puts "This is required for rete to know what classifies if a url is working or not!"
|
||||
puts "You can fix this by creating a config.txt file and by then entering status codes you classify as \"working\""
|
||||
exit(1)
|
||||
end
|
||||
|
||||
while repeat < ARGV.size
|
||||
begin
|
||||
response = HTTP::Client.get(ARGV[repeat])
|
||||
validUrl = Valid.url? ARGV[repeat]
|
||||
rescue Regex::Error
|
||||
validUrl = false
|
||||
end
|
||||
|
||||
if validUrl == true
|
||||
begin
|
||||
STDIN.read_timeout = 1
|
||||
uri = URI.parse(ARGV[repeat])
|
||||
client = HTTP::Client.new(uri)
|
||||
client.connect_timeout = urlTimeout.to_i.seconds
|
||||
|
||||
response = client.get("/")
|
||||
if config.includes?(response.status_code.to_s)
|
||||
puts "#{ARGV[repeat]} is a valid URL and works. Status code: #{response.status_code}"
|
||||
working += 1
|
||||
@@ -106,7 +126,7 @@ config = File.read("config.txt")
|
||||
puts "#{ARGV[repeat]} is a valid URL but does not work. Status Code: #{response.status_code}"
|
||||
notWorking += 1
|
||||
end
|
||||
rescue Socket::Addrinfo::Error
|
||||
rescue
|
||||
puts "#{ARGV[repeat]} is a valid URL but does not exist."
|
||||
notWorking += 1
|
||||
end
|
||||
@@ -115,10 +135,11 @@ config = File.read("config.txt")
|
||||
notWorking += 1
|
||||
end
|
||||
repeat += 1
|
||||
end
|
||||
end
|
||||
|
||||
puts "=============================="
|
||||
puts "Finished testing urls."
|
||||
puts "A total of #{repeat} url(s) were tested."
|
||||
puts "#{working}/#{repeat} url(s) were working."
|
||||
puts "#{notWorking}/#{repeat} url(s) were not working."
|
||||
puts "=============================="
|
||||
puts "Finished testing urls."
|
||||
puts "A total of #{repeat} url(s) were tested."
|
||||
puts "#{working}/#{repeat} url(s) were working."
|
||||
puts "#{notWorking}/#{repeat} url(s) were not working."
|
||||
exit 0
|
||||
Reference in New Issue
Block a user