From: Robert Klemme Date: 2010-10-29T15:07:33+09:00 Subject: Re: mechanize - extract href On Thu, Oct 28, 2010 at 8:54 PM, Corey Watts wrote: > Thanks!  I eventually came up with something like this: > > website = > page.search("//div[@class='listing_content']/ul[@class='features']/li[1]") Wouldn't it be better to first search for all div with class=listing_content and then extract data for that single listing from there? > # initializes the link variable with something > link = "super" "link = nil" is sufficient. > # The segment below grabs the URL of the listing's website, if it has > one.  Otherwise it > # puts 'nil' into the link variable > if website.inner_text() == "» Website" You can use my XPath to find those links. >  website.search("a").map do |l| #map is nonsense here - you only need #each. >    link = l['href'] >  end > else >  link = "nil" Didn't you mean "link = nil"? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/