diff options
author | Guillermo Ramos | 2024-06-08 10:46:49 +0200 |
---|---|---|
committer | Guillermo Ramos | 2024-06-08 10:46:49 +0200 |
commit | 97bf1464db70e27fa40aa6ee186dfbfd4c32259d (patch) | |
tree | 10d37b27e20ae1de813bc7080da01a9ae2832a90 | |
parent | a42c06f6108da26c1645190352252780b6655042 (diff) | |
download | bots-master.tar.gz |
-rwxr-xr-x | aesan_alerts.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/aesan_alerts.rb b/aesan_alerts.rb index 675c047..85db083 100755 --- a/aesan_alerts.rb +++ b/aesan_alerts.rb @@ -26,7 +26,17 @@ def read_title(file_path, line) end def fetch_first_paragraph(url) - response = Net::HTTP.get_response(URI.parse(url)) + response = nil + error = nil + (1..3).each do + response = Net::HTTP.get_response(URI.parse(url)) + break + rescue StandardError => error + sleep 5 + end + if response.nil? + abort "Error al descargar URL tras 3 intentos: #{error}" + end if response.is_a?(Net::HTTPSuccess) document = Nokogiri::HTML(response.body) @@ -45,7 +55,7 @@ def fetch_first_paragraph(url) puts ps end else - warn "Error al descargar página: #{response.code} #{response.message}" + abort "Error al descargar página: #{response.code} #{response.message}" end end |