Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > open_uri.rb -- 500 Internal Server Error

Reply
Thread Tools

open_uri.rb -- 500 Internal Server Error

 
 
Vikas Gholap
Guest
Posts: n/a
 
      01-17-2009
Hello to all,
I am using 'open-uri' & 'pp' ruby library, to open url and gather some
data from given web page. But it throws following error

c:/ruby/lib/ruby/1.8/open-uri.rb:278:in `open_http': 500 Internal Server
Error (
OpenURI::HTTPError)
from c:/ruby/lib/ruby/1.8/open-uri.rb:617:in `buffer_open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
from c:/ruby/lib/ruby/1.8/open-uri.rb:162:in `catch'
from c:/ruby/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
from c:/ruby/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
from c:/ruby/lib/ruby/1.8/open-uri.rb:519:in `open'
from c:/ruby/lib/ruby/1.8/open-uri.rb:30:in `open'
from openmyurl.rb:4


source code openurl.rb is like-----


require 'open-uri'
require 'pp'

open('http://www.aflatune.com/') do |f|
# hash with meta information
pp f.meta

#
pp "Content-Type: " + f.content_type
pp "last modified" + f.last_modified.to_s

no = 1
# print the first fifty lines
f.each do |line|
print "#{no}: #{line}"
no += 1
break if no > 50
end
end

can any one give me solution to how to solve this problem?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
badboy
Guest
Posts: n/a
 
      01-17-2009
Vikas Gholap schrieb:
> Hello to all,
> I am using 'open-uri' & 'pp' ruby library, to open url and gather some
> data from given web page. But it throws following error
>
> c:/ruby/lib/ruby/1.8/open-uri.rb:278:in `open_http': 500 Internal Server
> Error (
> OpenURI::HTTPError)
> from c:/ruby/lib/ruby/1.8/open-uri.rb:617:in `buffer_open'
> from c:/ruby/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
> from c:/ruby/lib/ruby/1.8/open-uri.rb:162:in `catch'
> from c:/ruby/lib/ruby/1.8/open-uri.rb:162:in `open_loop'
> from c:/ruby/lib/ruby/1.8/open-uri.rb:132:in `open_uri'
> from c:/ruby/lib/ruby/1.8/open-uri.rb:519:in `open'
> from c:/ruby/lib/ruby/1.8/open-uri.rb:30:in `open'
> from openmyurl.rb:4
>
>
> source code openurl.rb is like-----
>
>
> require 'open-uri'
> require 'pp'
>
> open('http://www.aflatune.com/') do |f|
> # hash with meta information
> pp f.meta
>
> #
> pp "Content-Type: " + f.content_type
> pp "last modified" + f.last_modified.to_s
>
> no = 1
> # print the first fifty lines
> f.each do |line|
> print "#{no}: #{line}"
> no += 1
> break if no > 50
> end
> end
>
> can any one give me solution to how to solve this problem?

looks like the aflatune-Webserver throws a 500 error if no User-Agent is
set.

this works for me:
open('http://www.aflatune.com/', 'User-Agent'=>'ruby')

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The Web server reported the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/822319ev1'. 'HTTP/1.1 500 Internal Server Error'. chanmm ASP .Net 2 09-07-2010 07:37 AM
System.Net.WebException: The remote server returned an error: (500) Internal Server Error. kuladeep.mohan@gmail.com ASP .Net 5 08-26-2009 09:36 AM
The remote server returned an error: (500) Internal Server Error. BobbyOwens ASP .Net 0 01-23-2009 11:04 AM
System.Net.WebException: The remote server returned an error: (500) Internal Server Error. kuladeep.mohan@gmail.com ASP .Net Web Services 0 03-24-2006 03:10 PM
Web server reported following error... HTTP/1.1 500 Internal Server Error John Bonds ASP .Net 2 08-03-2004 10:03 PM



Advertisments