[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

ruby cgi

lloyd@binaryten.com

6/3/2006 4:06:00 PM

can someone suggest a better implementation of this cgi ruby tool so
that i can return the results to the calling page... its my first
venture into cgi... www.binaryten.com/english/webtool

3 Answers

Tim Hammerquist

6/3/2006 6:11:00 PM

0

lloyd@binaryten.com <lloyd@binaryten.com> wrote:
> can someone suggest a better implementation of this cgi ruby tool so
> that i can return the results to the calling page... its my first
> venture into cgi... www.binaryten.com/english/webtool

All I see is a webpage. It's difficult to suggest a *better*
implementation if we can't see an implementation to start with.

Tim Hammerquist

lloyd@binaryten.com

6/4/2006 1:34:00 PM

0

you are quite right. I forgot (oops)... here it is...

#!/usr/bin/ruby
print "Content-type: text/html\r\n\r\n"
require 'net/http'
require 'cgi'
def findpage(url,searchterm,start=1,pagesize=100)
if pagesize < 1
print "<p>Current site position:#{start}</p>"
exit
end
page =
"/search?q=#{searchterm}&hl=en&start=#{start}&num=#{pagesize}"
file = Net::HTTP.start("www.google.com")
header,text = file.get(page)
text.each do |line|
m = /<a class=l href=\"#{url}/
if m =~ line
pagesize /= 10
findpage(url,searchterm,start,pagesize)
exit
end
end
start += pagesize
if start < 1000
findpage(url,searchterm,start,pagesize)
else
p "the site is not listed in the first 1000"
end
end

formdata = CGI.new
url = "http://#{formdata['url']}"
searchterm = CGI::escape(formdata['phrase'])
findpage(url,searchterm)

also, I wanted to know of a way to easily pass the value back into the
original page with the form.


Tim Hammerquist wrote:
> lloyd@binaryten.com <lloyd@binaryten.com> wrote:
> > can someone suggest a better implementation of this cgi ruby tool so
> > that i can return the results to the calling page... its my first
> > venture into cgi... www.binaryten.com/english/webtool
>
> All I see is a webpage. It's difficult to suggest a *better*
> implementation if we can't see an implementation to start with.
>
> Tim Hammerquist

anne001

6/8/2006 7:23:00 AM

0

> > > can someone suggest a better implementation of this cgi ruby tool so
> > > that i can return the results to the calling page... its my first
> > > venture into cgi...
>
> also, I wanted to know of a way to easily pass the value back into the
> original page with the form.

Better in what sense? Your question is how to return results to the
first page?

I am new to cgi and ruby, so I may not be able to help.

In the example I worked on, I wrote a code which presents a tool, the
tool searches for the
information on the web, and I create a new web page to present the
results.

It seems to me that if your first page is generated by cgi code, you
can regenerate it
with the results of your search included?