vbscript 使用 IE 自动填充在线网页
vbscript to autofill the online webpage using IE
我是 vb 脚本的新手。对在线网页中的数据输入进行自动化。下面的脚本打开一个网站但没有输入值并单击搜索以获取案例。有人可以帮忙调试下面的脚本吗?
下面是 HTML 来源,其中包含必须输入数据的文本框的 ID
Dim URL
Dim IE
Set IE = CreateObject("internetexplorer.application")
URL = "https://ecms.corporate/"
IE.Visible = True
IE.Navigate URL
Do While IE.Busy
WScript.Sleep 100
Loop
IE.document.getElementById("Request").value="231320"
好的,您是 VBS 的新手,也是本网站的新手。此资源用于 PowerShell 帮助,而不是 VBS。因此,尽管我们中的许多人都知道 VBS,但这并不是我们在这里提供帮助的目的。
至于你的用例。网络上有很多关于如何使用多种语言执行此操作的示例。然而,由于我们在这里专注于 PowerShell,因此这就是在 PowerShell 中完成的方式。
首先你必须知道你正在使用的实际元素,但你没有展示你是如何得到它的。您确定您正在为您的站点使用正确的页面元素吗 - 可以肯定。导航站点表单元素,而不是 Internet Explorer 元素
# Discover all page/form and elements to work with
$url = 'https://pwpush.com'
($FormElements = Invoke-WebRequest -Uri $url -SessionVariable fe)
($Form = $FormElements.Forms[0]) | Format-List -Force
$Form | Get-Member
$Form.Fields
# Interact with the site page
$password = '1234'
$loginUrl = 'https://pwpush.com'
$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.navigate($loginUrl)
while ($ie.Busy -eq $true) { Start-Sleep -Seconds 1 }
($ie.document.getElementById('password_payload') |
select -first 1).value = $password
Start-Sleep -Seconds 1
$ie.Document.getElementsByName('commit').Item().Click();
Start-Sleep -Seconds 1
虽然这个答案是在 PowerShell 中,但如果您坚持使用 VBS,过程是相同的,但只是使用 VBS 方法,如此处讨论:
Vbscript for automated website login testing
我是 vb 脚本的新手。对在线网页中的数据输入进行自动化。下面的脚本打开一个网站但没有输入值并单击搜索以获取案例。有人可以帮忙调试下面的脚本吗?
下面是 HTML 来源,其中包含必须输入数据的文本框的 ID
Dim URL
Dim IE
Set IE = CreateObject("internetexplorer.application")
URL = "https://ecms.corporate/"
IE.Visible = True
IE.Navigate URL
Do While IE.Busy
WScript.Sleep 100
Loop
IE.document.getElementById("Request").value="231320"
好的,您是 VBS 的新手,也是本网站的新手。此资源用于 PowerShell 帮助,而不是 VBS。因此,尽管我们中的许多人都知道 VBS,但这并不是我们在这里提供帮助的目的。
至于你的用例。网络上有很多关于如何使用多种语言执行此操作的示例。然而,由于我们在这里专注于 PowerShell,因此这就是在 PowerShell 中完成的方式。
首先你必须知道你正在使用的实际元素,但你没有展示你是如何得到它的。您确定您正在为您的站点使用正确的页面元素吗 - 可以肯定。导航站点表单元素,而不是 Internet Explorer 元素
# Discover all page/form and elements to work with
$url = 'https://pwpush.com'
($FormElements = Invoke-WebRequest -Uri $url -SessionVariable fe)
($Form = $FormElements.Forms[0]) | Format-List -Force
$Form | Get-Member
$Form.Fields
# Interact with the site page
$password = '1234'
$loginUrl = 'https://pwpush.com'
$ie = New-Object -com internetexplorer.application
$ie.visible = $true
$ie.navigate($loginUrl)
while ($ie.Busy -eq $true) { Start-Sleep -Seconds 1 }
($ie.document.getElementById('password_payload') |
select -first 1).value = $password
Start-Sleep -Seconds 1
$ie.Document.getElementsByName('commit').Item().Click();
Start-Sleep -Seconds 1
虽然这个答案是在 PowerShell 中,但如果您坚持使用 VBS,过程是相同的,但只是使用 VBS 方法,如此处讨论:
Vbscript for automated website login testing