wbsmith83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-25 02:23 UTC
Problem with Hpricot and attributes
I am trying to run the following code:
require ''rubygems''
require ''hpricot''
require ''open-uri''
doc = Hpricot(open("****the url is here***"))
tables =(doc/"table")
(tables[6]/"tr").each do |major|
name = major.search("td").first.inner_html
abbrev =major.search("acronym").inner_html
link = major.search("a")
path = link.attributes[''href'']
puts path
end
Everytime I run it, I get this error though: undefined method
`attributes'' for #<Hpricot::Elements[]> (NoMet
hodError)
Am I missing something?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 1/24/07, wbsmith83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <wbsmith83-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Everytime I run it, I get this error though: undefined method > `attributes'' for #<Hpricot::Elements[]> (NoMet > hodError)#search always returns an array of elements, even if it only found one. Use #at if you only want the first element. http://code.whytheluckystiff.net/hpricot/ -- Chris Wanstrath http://errtheblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---