4

I have to submit a form 1000 times to create objects for a website. They have given us access to do so, but no easy way to POST the data without using their website's form.

The form has these 4 inputs:

Textbox name = login
Textbox name = password
select name = region (values from 1 to 2000)
button name = submit

Is there any way to create a script that will select these elements in my browser and set values accordingly?

I thought about using AutoHotKey, but can't find any way to select web elements and fill in their values.

<form method="post" autocomplete="off" action="index.php?authorized=1">

<input name="login" maxlength="12" type="text">

<input name="password" value="" maxlength="30" type="password">

<select name="local_id">
    <option value="1">Washington D.C.</option>
    <option value="2">Chicago</option>
    ...(many more that i removed)
</select>

<input name="login_id" value="223" type="hidden">
<input name="dss" value="1" type="hidden">
<input name="action" value="createUser" type="hidden">
<input name="submit" value="Submit" type="submit">

</form>
flip66
  • 341
  • 2
  • 5
  • 17

2 Answers2

3

You'll need AutoHotkey_L (the most recently updated version), and then you can use the COM Interface for Internet Explorer. It can even fill in the forms, and not show up on your screen.

#NoEnv
#SingleInstance Force

; Settings
path := "http://domain.tld/path/to/form.html"

; Connect to IE
wb := ComObjCreate("InternetExplorer.Application")
wb.Visible := false

; Load the page specified
Load(wb, path)

; Find the first form on the page (put 1 for the second, 2 for the third, etc.)
Form := wb.Document.forms[0]

; Fill in data and submit it
Form["login"].value := "User"
Form["password"].value := "sUp3rS3cUr3"
Form["local_id"].value := "2"
Form["submit"].click()
return

Load(wb, what) {
    wb.Navigate(what)
    while wb.Busy
        continue
    wb.Visible := true
}

You may then instruct your script to Load the initial page again, and then fill in more data, and submit again. Just put a while wb.Busy loop in there so the php page can finish.

Brigand
  • 84,529
  • 20
  • 165
  • 173
-1
<html>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> //for jquery
<head>
<script>
$(function(){
$('form').submit(function()
{
for (a=0;a<1000;a++){
$(this).submit();
};
});
});
</script>
</head>
<body>
<form>
<input type='text' name='login' /><br />
<input type='password' name='password' /><br />
<select><script>$(function(){ for(a=0;a<=2000;a++){ $('select').prepend("<option>"+a+"</option>")}});</script>
</select>
<input type='submit' name='submit' />
</form>
</body>
</html>

I haven't tried that one but you may give this a try... Just an idea though cause I haven't tried it.

Please correct my code if it's wrong.(for other viewers).

o2kevin
  • 707
  • 1
  • 5
  • 20