A
akanksha
I am using open-uri for the first time. I need to visit a bunch of urls
and gather some data. Here is a samll code snippet
require 'open-uri' # allows the use of a file like API for URLs
open( "http://no-way-outspaik375.spaces.msn.com/") { |file|
lines = file.read
puts lines
}
and here is the error I get
ruby test.rb
/usr/local/lib/ruby/1.8/open-uri.rb:290:in `open_http': 500 Internal
Server Error (OpenURI::HTTPError)
from /usr/local/lib/ruby/1.8/open-uri.rb:629:in `buffer_open'
from /usr/local/lib/ruby/1.8/open-uri.rb:167:in `open_loop'
from /usr/local/lib/ruby/1.8/open-uri.rb:165:in `open_loop'
from /usr/local/lib/ruby/1.8/open-uri.rb:135:in `open_uri'
from /usr/local/lib/ruby/1.8/open-uri.rb:531:in `open'
from /usr/local/lib/ruby/1.8/open-uri.rb:86:in `open'
from test.rb:2
However
require 'open-uri' # allows the use of a file like API for URLs
open( "http://www.google.com/") { |file|
lines = file.read
puts lines
}
works just fine. What am I doing wrong??
and gather some data. Here is a samll code snippet
require 'open-uri' # allows the use of a file like API for URLs
open( "http://no-way-outspaik375.spaces.msn.com/") { |file|
lines = file.read
puts lines
}
and here is the error I get
ruby test.rb
/usr/local/lib/ruby/1.8/open-uri.rb:290:in `open_http': 500 Internal
Server Error (OpenURI::HTTPError)
from /usr/local/lib/ruby/1.8/open-uri.rb:629:in `buffer_open'
from /usr/local/lib/ruby/1.8/open-uri.rb:167:in `open_loop'
from /usr/local/lib/ruby/1.8/open-uri.rb:165:in `open_loop'
from /usr/local/lib/ruby/1.8/open-uri.rb:135:in `open_uri'
from /usr/local/lib/ruby/1.8/open-uri.rb:531:in `open'
from /usr/local/lib/ruby/1.8/open-uri.rb:86:in `open'
from test.rb:2
However
require 'open-uri' # allows the use of a file like API for URLs
open( "http://www.google.com/") { |file|
lines = file.read
puts lines
}
works just fine. What am I doing wrong??