您可以使用以下代码示例来解决此问题。
首先,请确保您已经安装了“Microsoft Internet Controls”和“Microsoft HTML Object Library”引用。
Sub SubmitDataToSecondaryWebsite()
Dim IE As InternetExplorer
Dim HTMLDoc As HTMLDocument
Dim Form As HTMLFormElement
Dim InputField As HTMLInputElement
Dim SubmitButton As HTMLInputElement
'Create new instance of Internet Explorer
Set IE = New InternetExplorer
'Navigate to secondary website
IE.Navigate "[次要网站的URL]"
'Wait for IE to load the page
Do While IE.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
'Get the HTML document of the page
Set HTMLDoc = IE.Document
'Get the form element of the page
Set Form = HTMLDoc.forms(0)
'Find and set the value for the input field
Set InputField = Form.elements("[输入字段的名称]")
InputField.Value = "[要输入的数据]"
'Find and click the submit button
Set SubmitButton = Form.elements("[提交按钮的名称]")
SubmitButton.Click
'Wait for IE to load the result page
Do While IE.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
'Close IE
IE.Quit
End Sub
以上代码将使用Internet Explorer来导航到次要网站,并在输入字段中设置数据并点击提交按钮。请根据次要网站的实际情况更改代码中的URL、输入字段和提交按钮的名称。
此外,请注意,使用IE对象可能会因IE版本不同而产生不同的结果。如果需要使用不同的浏览器,请查找相关的库和对象,并相应地更改代码。
上一篇:编写Excel宏VBA代码,实现在最新添加的行下方添加新行,并复制格式和公式。
下一篇:编写Express中间件以启用对GET、PUT、POST、DELETE的跨域访问控制-Allow-Origin。