From: 7stud -- Date: 2009-10-12T13:05:58+09:00 Subject: Re: Can't use variable from cgi with hpricot Wiley Davis wrote: > >> Other than that, your code looks ok to me, so I would check your form >> data. Something like the following should get recognized by cgi. > > Just to be sure, I checked the form and it looks okay. > >> CGI is a fickle little LIB, but she'll start to do your bidding once she >> feels that you know what you are doing. > > Darn... that'll be a while :) > >> If you just can't get CGI to read the form data, you can try to access >> the data using ARGV as if the string was a command line variable to your >> script. > > As noted below, cgi seems to be reading the string. I can read it and > display it with a: > > puts @linky > > but whenever i try to pass it along to hpricot, it gives me a server > error. Odd. What's the server error? I installed eruby, and I was able to configure eruby to work with my own Apache2 install on mac osx 10.4.11, (per the instructions in pickaxe2 p. 243 (a sym link didn't work, I actually had to copy the file into cgi-bin)) and despite my earlier post, your code works fine for me using Apache and localhost, although you can use open() with a block, and then you don't have to manually close the file: test.rhtml --------- html page
hi
world
<% require 'rubygems' require 'cgi' require 'open-uri' require 'hpricot' cgi = CGI.new linky = cgi['link'] open(linky) do |f| doc = Hpricot(f) title = doc/"title" puts title.inner_html end %>
--web browser displays:-- hi world pedalpower.com -- Posted via http://www.ruby-forum.com/.