Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #3883

Re: how to get variable text from browser

From Joe Pizzanley <pizzazjoe@yahoo.com>
Newsgroups comp.lang.ruby
Subject Re: how to get variable text from browser
Date 2011-05-03 12:36 -0500
Organization Service de news de lacave.net
Message-ID <8d6582f8bc7b97d12927a62f7c427fc9@ruby-forum.com> (permalink)
References <2c12d0a1cc624f5eefefe34ad6a18613@ruby-forum.com> <BANLkTikFNg7TifhDu7bNeBJRf+tJ0j7ocA@mail.gmail.com>

Show all headers | View raw


> 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.  Then I'm going to run a check on
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.

-- 
Posted via http://www.ruby-forum.com/.

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to get variable text from browser Joe Pizzanley <pizzazjoe@yahoo.com> - 2011-05-03 12:14 -0500
  Re: how to get variable text from browser Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-05-03 12:24 -0500
    Re: how to get variable text from browser Joe Pizzanley <pizzazjoe@yahoo.com> - 2011-05-03 12:36 -0500
      Re: how to get variable text from browser Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-05-03 12:48 -0500
        Re: how to get variable text from browser Joe Pizzanley <pizzazjoe@yahoo.com> - 2011-05-03 12:58 -0500
          Re: how to get variable text from browser Jesús Gabriel y Galán <jgabrielygalan@gmail.com> - 2011-05-04 02:03 -0500

csiph-web