W
Wiley Davis
I'm trying to get a url from a form and return the page title of said
url. I'm using cgi to get the web address from the url, which looks like
this:
http://somesite.com/result.rhtml?link=http://practicalpedal.com
The result page embedded ruby looks like this:
<%
require 'rubygems'
require 'cgi'
require 'open-uri'
require 'hpricot'
cgi = CGI.new
@linky = cgi['link'].to_str
@result = open(@linky)
@Doc = Hpricot(@result)
@title = (@Doc/"title").inner_html
@result.close
puts @title
%>
This works if I assign the @linky variable like so:
@linky = "http://practicalpedal.com"
But not when getting it with cgi. I'm very new at all of this, as is
probably obvious, but I can't figure this out. Any pointers in the right
direction would be appreciated.
url. I'm using cgi to get the web address from the url, which looks like
this:
http://somesite.com/result.rhtml?link=http://practicalpedal.com
The result page embedded ruby looks like this:
<%
require 'rubygems'
require 'cgi'
require 'open-uri'
require 'hpricot'
cgi = CGI.new
@linky = cgi['link'].to_str
@result = open(@linky)
@Doc = Hpricot(@result)
@title = (@Doc/"title").inner_html
@result.close
puts @title
%>
This works if I assign the @linky variable like so:
@linky = "http://practicalpedal.com"
But not when getting it with cgi. I'm very new at all of this, as is
probably obvious, but I can't figure this out. Any pointers in the right
direction would be appreciated.