# Is there an working example for rubyful\_soup on RoR?

**URL:** <https://www.ruby-forum.com/t/is-there-an-working-example-for-rubyful-soup-on-ror/102574>\
**Category:** Ruby\
**Created:** [November 7, 2006, 10:44am UTC](https://www.ruby-forum.com/t/is-there-an-working-example-for-rubyful-soup-on-ror/102574 "2006-11-07T10:44:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [November 7, 2006, 10:44am UTC](https://www.ruby-forum.com/t/is-there-an-working-example-for-rubyful-soup-on-ror/102574/1 "2006-11-07T10:44:39Z")

</div>

I found only Ruby language example to use rubyful\_soup.  
I don’t know if there’s a working example for RoR…

Basicall, I’ve done the following:

# in my controller, modified from someone’s blog

class GethttpController \< ApplicationController

require ‘net/http’  
require ‘uri’

require ‘rubygems’  
require ‘rubyful\_soup’

def fetch(uri\_str, limit = 10)

# You should choose better exception.

raise ArgumentError, ‘HTTP redirect too deep’ if limit == 0

response = Net::HTTP.get\_response(URI.parse(uri\_str))  
case response  
when Net::HTTPSuccess then Net::HTTP.get(URI.parse(uri\_str))  
when Net::HTTPRedirection then fetch(response[‘location’], limit - 1)  
else  
response.error!  
end  
end

def test  
@soup=nil  
@result=nil  
markup=nil  
markup = fetch('[http://www.ibm.com](http://www.ibm.com))  
@soup = BeautifulSoup.new(markup)

end

# end

In my view, only one line

Title:\<%= @soup.html.head.title.string%\>

================================================

the above code can run once and output right data.  
But if I refresh my browser, it’s not gonna work “again”.  
and I will encounter error messages

# from my log

ArgumentError (wrong number of arguments (5 for 1)):

C:/InstantRails-1.4-win/InstantRails/ruby/lib/ruby/gems/1.8/gems/rubyful\_soup-1.0.4/lib/rubyful\_soup.rb:609:in  
`initialize’  
C:/I
