On Tue, May 3, 2011 at 7:36 PM, Joe Pizzanley <pizzazjoe / yahoo.com> wrote: >> So, you want to fetch the page calling the URL, locate that text and >> extract the number part between parens? > > Not necessarily. I want to end up with "Files (7)" or whatever number it > happens to be as my variable value. ¨Âèåɧçïéîôï òõãèåãïî > it. > > > >> Something like: >> >> require 'open-uri' >> require 'nokogiri' # 'gem install nokogiri' first >> >> doc = Nokogiri::HTML(open(your_url).read) >> element = doc.css("your css selector expression here") >> # or element = doc.xpath("your xpath expression here") if you find it >> more suitable >> m = element.text.match /Files \((\d+)\)/ >> puts m[1] if m > > I'm a beginner and this is way too complicated for me to handle. > Isn't there a simpler way? $ie.text will grab ALL the text on the > browser page, but I just want that small bit. OK, you need to give a little bit more context. With the description you gave we couldn't know if you had already something or not. So, let me guess, $ie is a variable that holds a Watir browser? If so, there are two possibilities which might work, from your description. You might first locate the node in the DOM which contains the text, or you could try to run your regexp against the full text of the page. I guess $ie.text will return everything that is not inside an HTML tag, so it might work, depending on the rest of the page: m = $ie.text.match /Files\s+\(\d+\)/ if m files_text = m[0] else puts "Couldn't find the text in the page" end Jesus.