Forum: Ruby Help with Hpricot and collect

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
John Z. (Guest)
on 2008-12-18 02:48
Hi and thanks for the help, I am new to ruby and I am trying to get some
data from a website using the Hpricot library.I am doing this: links =
Hpricot(index_page).search("td.det_movie").collect{ |link| link["href"]
} to get an array of data but the thing is that right now I need some
text out of tags and the previous version only works with tags.
This is part of the code that I am reading, and I need the part that is
not in tags:

<table cellspacing="0" cellpadding="0" border="0" width="289">
<td height="5"/>
<td class="det_movie" align="left">6:25 9:20 p.m. (Mon./Fri.) 4:00 p.m.
(No previews) (Sat./Sun./Hol.) 1:00 p.m. (No previews) 3:30 p.m.</td>

the file is very large and I need all the objects with the

thanks for any help
Dan D. (Guest)
on 2008-12-18 12:22
(Received via mailing list)
require 'hpricot'

doc=Hpricot('<a class="link" href="detalle_movie.php?mv_id=618">The Day
the Earth Stood Still</a><a class="link"
href="detalle_movie.php?mv_id=618">The Day the Earth Stood Still</a>')

links=(doc/"//").collect do |link|

=> [
["detalle_movie.php?mv_id=618", "The Day the Earth Stood Still"],
["detalle_movie.php?mv_id=618", "The Day the Earth Stood Still"]
This topic is locked and can not be replied to.