From: Chad Perrin Date: 2011-05-04T02:41:09+09:00 Subject: Re: how to get variable text from browser --bg08WKrSYDhXBjb5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 04, 2011 at 02:14:13AM +0900, Joe Pizzanley wrote: > The browser page I'm working with has a semi-variable text group: "Files > (12)" >=20 > I want to turn that into a variable in my Ruby script: myfiles =3D "Files > (12)" >=20 > I surprised myself and figured out the regex to account for the changing > count: Files \(\d{0,999}\) but how do I grab it off of the browser > page? Can you arrange for the text group you want passed to your program to be passed via the URI used to access your program? For instance, if someone clicks a link in the page that contains "Files (12)" that points to this: http://example.com/cgi/your_script.rb =2E . . can you arrange for it to send this instead? http://example.com/cgi/your_script.rb?myfiles=3DFiles (12) If so, you can use the Ruby/CGI library to parse that: require 'cgi' cgi =3D CGI.new myfiles =3D cgi['myfiles'] (code untested, dredged from memory; hopefully it would work as written) --=20 Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ] --bg08WKrSYDhXBjb5 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk3AOwgACgkQ9mn/Pj01uKXS1wCeJAQMm6vPPXInN9++kVdxnpxd b/4AoMYJWM5VLjt6IJVPD8Puw/zW7Hlv =dmfT -----END PGP SIGNATURE----- --bg08WKrSYDhXBjb5--