我必须提交表单 1000 次才能为网站创建对象。他们已授予我们这样做的权限,但如果不使用他们网站的表单,则没有简单的方法来发布数据。
表单有这 4 个输入:
Textbox name = login
Textbox name = password
select name = region (values from 1 to 2000)
button name = submit
有没有什么方法可以创建一个脚本来在我的浏览器中选择这些元素并相应地设置值?
我考虑过使用 AutoHotKey,但找不到任何方法来选择 Web 元素并填写它们的值。
<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>
最佳答案
您需要 AutoHotkey_L(最新更新的版本),然后您可以使用 Internet Explorer 的 COM 接口(interface)。它甚至可以填写表格,而不会显示在您的屏幕上。
#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
}
然后您可以指示您的脚本再次加载
初始页面,然后填写更多数据,然后再次提交。只需在其中放置一个 while wb.Busy
循环,这样 php
页面就可以完成。
关于html - 创建一个脚本来填写表单值并提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17430997/