我在这个网站上。
https://brokercheck.finra.org/
我正在尝试使用VBA将数字放入第一个框("名称或CRD#")并按搜索。我无法弄清楚框中的信息如何。
这是HTML代码(对不起,如果没有足够的话),这就是我提供链接的原因。
> div layout-gt-xs="row" layout-xs="column" layout-align-xs="space-between center" class="layout-xs-column layout-gt-xs-row layout-align-xs-space-between-center"
>input type="text" ng-model="searchCtrl.name" placeholder="Name or CRD#" flex="auto" class="ng-pristine ng-valid flex-auto ng-empty ng-touched" aria-invalid="false" style=""
到目前为止,我的代码是:
Sub BrokerCheckSlim()
Dim objIE As InternetExplorer 'special object variable representing the IE browser
Set objIE = New InternetExplorer 'Creates IE object
objIE.Visible = True 'Can you see the browser?
objIE.navigate "https://brokercheck.finra.org/" 'Open Website
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop 'Keeps CPU from crashing
objIE.document.getElementsByClassName("ng-pristine ng-valid flex-auto ng-empty ng-touched").Item(0).Value = 1
objIE.document.getElementById("firm-input").Value = 1
objIE.document.getElementsByClassName("md-raised md-primary md-hue-2 md-button md-ink-ripple").Item(0).Click
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
End Sub
任何帮助都会受到赞赏。
由于
答案 0 :(得分:0)
找到此信息Entering data using VBA in to a HTML5 site
此代码填写该字段并单击按钮
按F5继续stop
Option Explicit
' found info here https://stackoverflow.com/questions/33667426/entering-data-using-vba-in-to-a-html5-site
Sub BrokerCheckSlim()
Dim objIE As InternetExplorer ' object variable representing the IE browser
Set objIE = New InternetExplorer ' instantiates IE object
objIE.Visible = True ' make browser visible
objIE.navigate "https://brokercheck.finra.org/"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop ' service other events while web page loads
objIE.document.getElementsByClassName("ng-pristine ng-untouched ng-valid flex-auto ng-empty").Item(0).Focus
objIE.document.getElementsByClassName("ng-pristine ng-untouched ng-valid flex-auto ng-empty").Item(0).innertext = "smith"
With objIE.document.getElementsByClassName("md-raised md-primary md-hue-2 md-button md-ink-ripple").Item(0) ' using the "with" statement to refer to objects
.Focus
.Click
End With
' objIE.document.getElementById("firm-input").Value = 1
' Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
Stop ' press F5 of F8 to continue
objIE.Quit
Set objIE = Nothing
End Sub
答案 1 :(得分:0)
由于复合类名称并不总是很好的标志,我试图使刮刀略有不同。下面的脚本将允许您在第一个搜索框中输入该名称,然后按下单击按钮。试一试:
boost::optional