1

How to automate the submission of html form, with random text values using vbscript?

Arun Annamalai
  • 785
  • 1
  • 7
  • 20

3 Answers3

2

You can use the "Microsoft.XMLHTTP" to automate the form submittal. Please see below:

Set xml = Server.CreateObject("Microsoft.XMLHTTP")

' Notice the two changes in the next two lines:
xml.Open "POST", "http://www.imdb.com/Find", False
xml.Send "select=All&for=The Usual Suspects"

wscript.echo xml.responseText

Or take a look at these great posts:

https://web.archive.org/web/20210728074446/https://www.4guysfromrolla.com/webtech/110100-1.2.shtml

https://web.archive.org/web/20210927184623/http://www.4guysfromrolla.com/webtech/110100-1.shtml

http://support.microsoft.com/kb/290591

mrTomahawk
  • 944
  • 1
  • 7
  • 14
  • This would be correct in the case of ASP. But this does not work automation of form submission from a normal (*.vbs) file. – Arun Annamalai May 22 '09 at 11:00
  • I don't know what you mean. The example I showed has nothing to do with server side code being ASP, it could CGI, PHP, hell even Ruby all that matters is that you submit the values expected by the server side code during a form submit. You also asked how it could be done using VBScript, which is what my example(s) are showing. Can you revise your to maybe emphasize what problem your trying to overcome? – mrTomahawk May 27 '09 at 13:49
  • I guess Smart Pandian means that `Server` is ASP-specific object, which is not available in Windows Script Host (he says he uses *.vbs files, that is, runs code as a Windows script, not web script). In this case, the first statement should be changed to `Set xml = CreateObject("Microsoft.XMLHTTP")`. – Helen Feb 01 '10 at 10:39
0

You may want to use Selenium (http://seleniumhq.org/) or Waitr (http://wtr.rubyforge.org/) as they will allow you better control and are built to do what you are looking for.

Josh
  • 590
  • 3
  • 4
-1
<html>
    <form action='http://127.0.0.1/file.php' method='POST' id=1>
        <input type=hidden name="var" value="val">
        <input type=submit>
    </form>
</html>
<script>
    document.getElementById(1).submit();
</script>
rook
  • 66,304
  • 38
  • 162
  • 239