Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Form Filler

Reply
Thread Tools

Form Filler

 
 
eastcoastcoder@gmail.com
Guest
Posts: n/a
 
      02-14-2006
Is there an equivalent in Ruby to the Perl modules which can "fill out
an html/http form"?

Given a hash, I'd like to either get the query string to append to the
URL for GET's, or the POST contents to append for POST's, as if the
hash was the form[field] = value. The routine should handle the url
encoding and the like.

Any luck?
(If not, anyone up for a quick few lines of Ruby ninjahood?)

 
Reply With Quote
 
 
 
 
ara.t.howard@noaa.gov
Guest
Posts: n/a
 
      02-14-2006
On Tue, 14 Feb 2006 http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Is there an equivalent in Ruby to the Perl modules which can "fill out
> an html/http form"?
>
> Given a hash, I'd like to either get the query string to append to the
> URL for GET's, or the POST contents to append for POST's, as if the
> hash was the form[field] = value. The routine should handle the url
> encoding and the like.
>
> Any luck?
> (If not, anyone up for a quick few lines of Ruby ninjahood?)


harp:~ > cat a.rb
require "cgi"

class ::Hash
def query() map{|k,v| [CGI::escape(k), CGI::escape(v)].join "="}.join "&" end
end

query = { "foo" => "< > &", "bar" => "http://b/a space" }

puts query.query


harp:~ > ruby a.rb
foo=%3C+%3E+%26&bar=http%3A%2F%2Fb%2Fa+space


hth.

-a

--
judge your success by what you had to give up in order to get it.
- h.h. the 14th dali lama


 
Reply With Quote
 
 
 
 
Kev Jackson
Guest
Posts: n/a
 
      02-14-2006

>
> harp:~ > cat a.rb
> require "cgi"
>
> class ::Hash
> def query() map{|k,v| [CGI::escape(k), CGI::escape(v)].join
> "="}.join "&" end
> end
>
> query = { "foo" => "< > &", "bar" => "http://b/a space" }
>
> puts query.query
>
>
> harp:~ > ruby a.rb
> foo=%3C+%3E+%26&bar=http%3A%2F%2Fb%2Fa+space
>
>

6 minutes from post to solution - is that a record?

Kev


 
Reply With Quote
 
ara.t.howard@noaa.gov
Guest
Posts: n/a
 
      02-14-2006
On Tue, 14 Feb 2006, Kev Jackson wrote:

> 6 minutes from post to solution - is that a record?


i think i got one in under 2 before...

-a

--
judge your success by what you had to give up in order to get it.
- h.h. the 14th dali lama


 
Reply With Quote
 
David Vallner
Guest
Posts: n/a
 
      02-14-2006
D=C5=88a Utorok 14 Febru=C3=A1r 2006 05:19 Kev Jackson nap=C3=ADsal:
> > harp:~ > cat a.rb
> > require "cgi"
> >
> > class ::Hash
> > def query() map{|k,v| [CGI::escape(k), CGI::escape(v)].join
> > "=3D"}.join "&" end
> > end
> >
> > query =3D { "foo" =3D> "< > &", "bar" =3D> "http://b/a space" }
> >
> > puts query.query
> >
> >
> > harp:~ > ruby a.rb
> > foo=3D%3C+%3E+%26&bar=3Dhttp%3A%2F%2Fb%2Fa+space

>
> 6 minutes from post to solution - is that a record?
>
> Kev


Ara's time machine is almost as good as Guido's time machine, it seems.

Oh, and someone apparently hacked up a Ruby WWW::Mechanize which is suppose=
d=20
to do this.

David Vallner


 
Reply With Quote
 
eastcoastcoder@gmail.com
Guest
Posts: n/a
 
      02-15-2006
Excellent, most appreciated.

Forgive my RFC ignorance, but is the same string appended to the URL
for GETs and sent as the bod for POST's? Or is there a difference in
the encoding somehow?

 
Reply With Quote
 
ara.t.howard@noaa.gov
Guest
Posts: n/a
 
      02-15-2006
On Wed, 15 Feb 2006 (E-Mail Removed) wrote:

> Excellent, most appreciated.
>
> Forgive my RFC ignorance, but is the same string appended to the URL
> for GETs and sent as the bod for POST's? Or is there a difference in
> the encoding somehow?


it certainly is different. google around for more info. you'll need to use
something like http-access2 for posting form data. check out my rubyforge
script (on rubyforge no less) for a pretty complete example of posting
including file uploads and redirects.

regards.

-a

--
judge your success by what you had to give up in order to get it.
- h.h. the 14th dali lama


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto Form Filler - Try This - Russ Pyne Windows 64bit 1 05-25-2005 11:14 AM
PDF form filler Andrew Morrison Computer Support 9 10-15-2003 04:35 PM
free form filler not spyware bUbBlEwRaP Computer Support 1 08-22-2003 08:36 PM
<tr> with a 1x1 image as a filler on a table with padding of 2 look thicker in netscape but they look ok in IE. Serial # 19781010 HTML 1 08-10-2003 09:05 PM
Re: Omni Form Filler? JM Computer Support 0 07-18-2003 06:18 PM



Advertisments