another stupid question: filling out webforms

S

stefan s.

hi

i´d like to fill out a html webform with ruby with randomly generated
values. an example:

- the form is @ www.mypage.com/webform.html
- there´s one field in this form: "zip" (<input type="text" name="zip">)
- i should be filled out with a random text-value smaller than 8 characters
by the ruby script

please help me!

p.s. excuse my bad english :)
 
B

Bermejo, Rodrigo

Try this...


def random_text

letters = ("a".."z").to_a

letters.each_index do | l |

r = rand(letters.length - 1);

letters[l],letters[r] =letters[r],letters[l]

end

string = letters[0,rand(8)].to_s

if string.empty?
random_text
else
return string
end

end

print %^<input type="text" name="zip" value=#{random_text}>^



it is what you are looking for ?
 
A

Ara.T.Howard

Date: Wed, 26 Nov 2003 16:07:31 +0100
From: stefan s. <[email protected]>
Newsgroups: comp.lang.ruby
Subject: another stupid question: filling out webforms

hi

i´d like to fill out a html webform with ruby with randomly generated
values. an example:

- the form is @ www.mypage.com/webform.html
- there´s one field in this form: "zip" (<input type="text" name="zip">)
- i should be filled out with a random text-value smaller than 8 characters
by the ruby script

please help me!

p.s. excuse my bad english :)

problem one:

~/eg/ruby/http > lynx -source http://www.mypage.com/webform.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"> <HTML><HEAD><TITLE>The page cannot be
found</TITLE> <META HTTP-EQUIV="Content-Type" Content="text/html;
charset=Windows-1252"> <STYLE type="text/css"> BODY { font: 8pt/12pt verdana }
H1 { font: 13pt/15pt verdana } H2 { font: 8pt/12pt verdana } A:link { color:
red } A:visited { color: maroon } </STYLE> </HEAD><BODY><TABLE width=500
border=0 cellspacing=10><TR><TD>
<h1>The page cannot be found</h1> The page you are looking for might have been
removed, had its name changed, or is temporarily unavailable. <hr> <p>Please
try the following:</p> <ul> <li>Make sure that the Web site address displayed
in the address bar of your browser is spelled and formatted correctly.</li>
<li>If you reached this page by clicking a link, contact the Web site
administrator to alert them that the link is incorrectly formatted. </li>
<li>Click the <a href="javascript:history.back(1)">Back</a> button to try
another link.</li> </ul> <h2>HTTP Error 404 - File or directory not
found.<br>Internet Information Services (IIS)</h2> <hr> <p>Technical
Information (for support personnel)</p> <ul> <li>Go to <a
href="http://go.microsoft.com/fwlink/?linkid=8180">Microsoft Product Support
Services</a> and perform a title search for the words <b>HTTP</b> and
<b>404</b>.</li> <li>Open <b>IIS Help</b>, which is accessible in IIS Manager
(inetmgr), and search for topics titled <b>Web Site Setup</b>, <b>Common
Administrative Tasks</b>, and <b>About Custom Error Messages</b>.</li> </ul>
</TD></TR></TABLE></BODY></HTML>


-a
--

ATTN: please update your address books with address below!

===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| STP :: http://www.ngdc.noaa.gov/stp/
| NGDC :: http://www.ngdc.noaa.gov/
| NESDIS :: http://www.nesdis.noaa.gov/
| NOAA :: http://www.noaa.gov/
| US DOC :: http://www.commerce.gov/
|
| The difference between art and science is that science is what we
| understand well enough to explain to a computer.
| Art is everything else.
| -- Donald Knuth, "Discover"
|
| /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done'
===============================================================================
 
S

stefan s.

hi

thx for helping me!


Bermejo said:
Try this...


def random_text

letters = ("a".."z").to_a

letters.each_index do | l |

r = rand(letters.length - 1);

letters[l],letters[r] =letters[r],letters[l]

end

string = letters[0,rand(8)].to_s

if string.empty?
random_text
else
return string
end

end

print %^<input type="text" name="zip" value=#{random_text}>^



it is what you are looking for ?




hi

i´d like to fill out a html webform with ruby with randomly generated
values. an example:

- the form is @ www.mypage.com/webform.html
- there´s one field in this form: "zip" (<input type="text" name="zip">)
- i should be filled out with a random text-value smaller than 8 characters
by the ruby script

please help me!

p.s. excuse my bad english :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top