From: Elliot Temple Date: 2006-06-07T15:47:03+09:00 Subject: open-uri error I am writing a script to download warcraft 3 replays for me. It got a few (which work) then had an error: URI::InvalidURIError: bad URI(is not URI?): http://ftp.replays.net/ w3g/060607/060606_mYm]Lucifer(UD)_vs_mTw-LasH(Hum)_TwistedMeadows_RN.w3g The URL works in Safari, so I'm not sure what's going on. My wild guess is that Safari accepts technically invalid URLs. Hopefully someone knowledgeable can tell me what the issue is. Here's my code: require "open-uri" path = "/Applications/Warcraft\ III/Replay/auto/" files = Dir.glob "#{path}*" count = 0 urls = `lynx -dump http://war3.replays.net/`.split "\n" urls = urls.select { |url| url =~ %r-\d{1,3}\. http://ftp.replays.net/ w3g- } urls = urls.collect { |url| url.sub(%r-\s*\d{1,3}\.\s*-, "")} urls.each do |url| filename = url.sub(%r-http://ftp.replays.net/w3g/\d*/-, "") if not files.include?(filename) open(url) do |remote_file| File.open(path + filename, "w") do |local_file| local_file.write remote_file.read count += 1 end end end end puts "I got #{count} files!" -- Elliot Temple http://www.curi.us/blog/