Hello,
I’m trying to use a ruby program to grab html outside of my domain and
alter it for use in another page in my domain. This is a proxy, right?
I thought I wouldn’t have a problem with this but… I do.
<%
require “cgi”
require “open-uri”
cgi = CGI.new()
url = cgi.params[‘myURL’]
htmlDoc = “”
test = open(url)
test.each() do |line|
htmlDoc += line
end
%>
<%= htmlDoc %>
When I ask for this program in a GET request I’m asked if I want to save
the file rather than getting a display of the html. I’m sure this is
just some stupid noob mistake I’m making. Any help would be
appreciated.
Best,
Max
OpenURI can be used to open files. A script like this would be a major
security problem. The problem here with being asked to save it is that
you aren’t sending the proper MIME type. Look at the CGI docs for how
to do this.
OpenURI can be used to open files. A script like this would be a major
security problem. The problem here with being asked to save it is that
you aren’t sending the proper MIME type. Look at the CGI docs for how
to do this.
Ok, I’m still having some trouble getting this to work. I looked at the
cgi docs but find them a little daunting. Is there some example code
someone could point me to?
Thanks.
OpenURI can be used to open files. A script like this would be a major
security problem. The problem here with being asked to save it is that
you aren’t sending the proper MIME type. Look at the CGI docs for how
to do this.
Ok, I’m still having some trouble getting this to work. I looked at the
cgi docs but find them a little daunting. Is there some example code
someone could point me to?
Thanks.
Maybe an apache server with mod_ruby installed is what you needed,
google “mod_ruby” plz!
–
For some reasons,my EMail had been changed to “kdr2[#]163.com” now…
NO GNUS is Bad News.
------yours Killy Draw
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.