# Hpricot question

**URL:** <https://www.ruby-forum.com/t/hpricot-question/83284>\
**Category:** Ruby\
**Created:** [January 24, 2007, 9:50pm UTC](https://www.ruby-forum.com/t/hpricot-question/83284 "2007-01-24T21:50:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 24, 2007, 9:50pm UTC](https://www.ruby-forum.com/t/hpricot-question/83284/1 "2007-01-24T21:50:41Z")

</div>

In a statement like this:

doc=Hpricot(open(url))

Is there a way to pull the url as a value from a database?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 25, 2007, 6:01pm UTC](https://www.ruby-forum.com/t/hpricot-question/83284/2 "2007-01-25T18:01:39Z")

</div>

removed\_email\_address@domain.invalid wrote:

> In a statement like this:
> 
> doc=Hpricot(open(url))
> 
> Is there a way to pull the url as a value from a database?

lets say you’ve done this in your controller where the Feed is a model  
with a url field in it.

–feed\_controller.rb

def pullfeed  
@feed = Feed.find(params[:id])  
Parsefeed.parse(@feed.id)  
end

The @feed can be used to fetch the field with a url in it, in your  
hpricot model.  
if you have required ‘open-uri’ in your model. otherwise hpricot can  
only open local resources.

–parsefeed.rb is a model not subclassed from ActiveRecord if not  
needed

class Parsefeed  
require ‘hpricot’  
require ‘open-uri’

def self.parse(feedID)  
doc=[]  
@feed = Feed.find(feedID)  
doc = Hpricot(open(@feed.url)) #this is where you employ the url  
from the database model  
  
end  
end
