newbie-question: Type Conversion

M

M P

I am using the Hpricot(which is awesome!) ruby module to do screen
scraping. When I retrieve a list of search results, it returns a
custom data type "Hpricot::Elements." I am trying to treat this
returned list as an array, but keep getting errors. How can I convert
this to an array of my results? I have tried '.to_a' but that doesn't
work.


Thank You for your time. Here is a code example:

doc = Hpricot(open("my url"))
@conts = doc.search("form[@name='form']/div")
 
M

M P

Nevermind, I figured it out with:

@conts.methods.each { |x|
puts "******************************" #for readability
puts x
puts "******************************"
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,263
Messages
2,571,312
Members
47,987
Latest member
Gaurav

Latest Threads

Top