Skip to content

Commit fc47088

Browse files
committed
fix URI.escape and URI.open deprecation warnings
Fixes #6 $ ./bin/nom search foo Previous log entries: (no matching entries found) --------------------- (0) total .../lib/nom/nom.rb:109: warning: URI.escape is obsolete .../lib/nom/nom.rb:111: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open .../lib/nom/nom.rb:115: warning: calling URI.open via Kernel#open is deprecated, call URI.open directly or use URI#open Food Diet Pro, Schoko (Powerstar Food) (707) 1 Glas (200 ml) (106) 1 Becher (30 ml) As the stdlib [1] and the warnings suggest, use CGI.escape and URI.open instead. [1]: https://ruby-doc.org/stdlib-2.7.1/libdoc/uri/rdoc/URI/Escape.html#method-i-escape-label-Description
1 parent ceb4530 commit fc47088

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/nom/nom.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ def search args
106106
term = args.join(" ")
107107
puts
108108
term = term.encode("ISO-8859-1")
109-
url = "https://fddb.info/db/de/suche/?udd=0&cat=site-de&search=#{URI.escape(term)}"
109+
url = "https://fddb.info/db/de/suche/?udd=0&cat=site-de&search=#{CGI.escape(term)}"
110110

111-
page = Nokogiri::HTML(open(url))
111+
page = Nokogiri::HTML(URI.open(url))
112112
results = page.css(".standardcontent a").map{|a| a["href"]}.select{|href| href.include? "lebensmittel"}
113113

114114
results[0..4].each do |result|
115-
page = Nokogiri::HTML(open(result))
115+
page = Nokogiri::HTML(URI.open(result))
116116
title = page.css(".breadcrumb a").last.text
117117
brand = page.css(".standardcontent p a").select{|a| a["href"].include? "hersteller"}.first.text
118118
puts "#{title} (#{brand})"

0 commit comments

Comments
 (0)