[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

newbie-question: Type Conversion

spwpreston

3/8/2008 5:28:00 AM

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")
1 Answer

spwpreston

3/8/2008 5:38:00 AM

0

Nevermind, I figured it out with:

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