From: "Jesús Gabriel y Galán" Date: 2012-10-10T05:27:40+09:00 Subject: Re: SocketError when letting ruby open url from txt-file On Tue, Oct 9, 2012 at 7:58 PM, Sybren Kooistra wrote: > It's half a million files.. So I don't know if printing the file first > would help (or what exactly do you mean)? Yes, I meant that there's probably some bad (invalid) uris. Or maybe garbage in the file. > Is there a way to workaround possible bad-urls Catch the exception and log the line, for example: File.foreach("websites.txt") do |line| #loop on basis urls textfile begin searchablefile = Nokogiri::HTML(open(line)) #open each url # the rest of the logic rescue puts "there was an error opening #{line}" end end Jesus.