需要单击搜索按钮但没有按钮ID,类名

问题描述 投票:1回答:1

我是这个论坛的新手...请解决我的下面的问题:我想点击搜索按钮打开我可以搜索的新页面,但我无法点击搜索按钮,因为在检查元素代码中只给出了按钮名称。下面是元素代码。

按钮类型=“按钮”on click =“window.location ='Go?action = agent'”搜索/按钮

请建议使用VBA代码单击搜索按钮。抱歉,但我无法提供网址,因为它无法在办公室外工作。

感谢下面的代码,我可以登录页面,我可以转到搜索按钮在那里的页面后,我卡在该页面上。

Sub login_page()

Dim IE App As Internet Explorer

Dim IE Doc As Object

'create a new instance of IE
Set IE App = New Internet Explorer

IE App.Visible = True

IE App.navigate "URL"

Do While IE App.Busy: Do Events: Loop

Do Until IE App.ready State = READY STATE_COMPLETE: Do Events: Loop

Set IE Doc = IE App.document

With IE Doc.forms(0)

.user.Value = "id"

.Password.Value = "password"

.submit

End With
IE App.navigate "hyperlink URL"

Do While IE App.Busy: Do Events: Loop

'Do Until IE App.ready State = READY STATE_COMPLETE: Do Events: Loop

IE App.navigate "hyperlink URL"

Do While IE App.Busy: Do Events: Loop

IE App.navigate "hyperlink URL"

Do While IE App.Busy: Do Events: Loop

ieApp.document.getElementsById("go").Value = "123"


 With ieApp.document
  .getElementById("go").Value = "123"

End With

ieApp.document.parentWindow.getElementsbyid("go").Value = "123"




ieApp.document.parentWindow.getElementbyid("go").Value = "123"


ieApp.document.getElementById("go").Value = "123"


End Sub
excel vba web-scraping
1个回答
0
投票

尝试下面我直接运行onclick事件javascript的内容。

 ieApp.document.parentWindow.execScript "window.location='Go?action=agent'" 
© www.soinside.com 2019 - 2024. All rights reserved.