lib/ietfbib/scrapper.rb in ietfbib-0.4.3 vs lib/ietfbib/scrapper.rb in ietfbib-0.4.4

- old
+ new

@@ -32,18 +32,23 @@ warn "#{ref}: not recognised for RFC" return end uri = uri.gsub("CODE", ref) - res = Net::HTTP.get_response(URI(uri)) - if res.code != "200" + begin + res = Net::HTTP.get_response(URI(uri)) + if res.code != "200" + warn "No document found at #{uri}" + return + end + doc = Nokogiri::HTML Net::HTTP.get(URI(uri)) + @reference = doc.at('//reference') + return unless @reference + bib_item + rescue warn "No document found at #{uri}" return end - doc = Nokogiri::HTML Net::HTTP.get(URI(uri)) - @reference = doc.at('//reference') - return unless @reference - bib_item end private # rubocop:disable Metrics/MethodLength