Logging now tells you how many URLs the script has checked so far

This commit is contained in:
Taevas 2021-03-07 16:30:48 +01:00
parent b0ec265695
commit 829c833f50
4 changed files with 14 additions and 14 deletions

View file

@ -3,14 +3,14 @@ require 'json'
def main_loop
json_object = []
TIMES.times do
TIMES.times do |i|
url = url_generator()
puts(url) if LOG
puts("#{url} (#{i + 1}/#{TIMES})") if LOG
begin
response = Net::HTTP.get_response(URI(url))
puts("#{url} exists!")
json_object << Hash["website_url" => url, "response_type" => "SUCCESS", "response_code" => response.code, "response_details" => response.message]
rescue Exception => e # Unlike JS/PY, the number of existing websites that raise exceptions is small
rescue Exception => e # Unlike Node/PY, the number of existing websites that raise exceptions is small
if e.class != SocketError
puts("#{url} exists!")
json_object << Hash["website_url" => url, "response_type" => "ERROR", "response_code" => e.class.to_s, "response_details" => e.to_s]