Is there an equivalent ruby/RoR method for PHP get_meta_tags.
I am looking to read the meta tag information of a given url
Is there an equivalent ruby/RoR method for PHP get_meta_tags.
I am looking to read the meta tag information of a given url
You could try using Hpricot and do something like:
doc = Hpricot(URI.parse("http://example.com/").read)
(doc/'/html/head/meta')
#=> Elements[...]
Thanks a lot.
It work for me. I am trying to get description form meta tag. my code is like
def self.extract_description_from_url(url)
description = ""
doc = Hpricot(URI.parse(url).read)
(doc/'/html/head/meta').each do |meta|
val= meta.get_attribute('name')
if val == "description"
description = meta.get_attribute('content')
end
end
return description
end