javascript - 从单页 Web 应用程序进行 Vba Web 抓取
问题描述
大家好,任何人都可以帮助我,我必须在 InputBox 中输入一些值,然后单击“搜索”按钮。根据该 InputBox 值数据显示在同一页面中而无需更改其 URL。我制作了一个代码,它在输入框中输入了一个值,但是当代码点击搜索按钮时,弹出窗口显示输入框为空
检查 InputBox 的元素
<input id="u_edi_claim_key0" placeholder="" ng-model-options="{ allowInvalid: true }" name="u_edi_claim_key0" type="text" class="form-control input-sm ng-valid ng-valid-maxlength ng-touched ng-dirty ng-valid-parse ng-empty" ng-model="searchController.Obj[tab.id+':'+data.displayID]" capitalize="u_fln_dcc">
检查 SearchButton 的元素
<button type="submit" id="Search" class="btn btn-primary btn-sm ng-binding" data-toggle="tooltip" ng-click="searchController.performSearch()" ng-disabled="searchController.callInProgress || searchController.searchForm.u_edi_claim.$invalid" title="Click this button to perform the search.">
Sub macro()
Dim a As String
Dim IE As InternetExplorerMedium
Set IE = New InternetExplorerMedium
Dim Ist As IHTMLElementCollection
Dim i As IHTMLElement
IE.Visible = True
a = "https://doc30-ui.uhg.com/doc30-ui/search"
IE.navigate a
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
Application.Wait Now + TimeValue("00:00:3")
Dim DOC As New HTMLDocument
Set DOC = IE.document
Set Ist = DOC.getElementsByTagName("input")
For Each i In Ist
If i.ID = "u_edi_claim_key0" Then
i.Focus
i.Select
i.Value = 66827839
End If
DOC.getElementById("Search").Click
Next
MsgBox "done"
End Sub
解决方案
Sub macro()
Dim a As String
Dim IE As InternetExplorerMedium
Set IE = New InternetExplorerMedium
Dim Ist As IHTMLElementCollection
Dim i As IHTMLElement
IE.Visible = True
a = "https://doc30-ui.uhg.com/doc30-ui/search"
IE.navigate a
Do While IE.ReadyState <> READYSTATE_COMPLETE
Loop
Application.Wait Now + TimeValue("00:00:3")
Dim DOC As New HTMLDocument
Set DOC = IE.document
Set Ist = DOC.getElementsByTagName("input")
For Each i In Ist
If i.ID = "u_edi_claim_key0" Then
i.Focus
i.Select
i.Value = 66827839
Exit For
Application.Sendkeys "~"
End If
Next
Application.Sendkeys "~"
MsgBox "done"
End Sub
推荐阅读
- sql - 数据库中的哪个查询更好?
- python - 在 Python 中的 (x,y) 图形上创建随机点
- mongodb - mongodb jest 错误 ReferenceError: You are trying to `import` a file after the Jest environment has been torn down
- javascript - 合并具有不同属性名称的数组值
- angular - 将表格列包装到pdfMake中的下一行
- c++ - opengl - glBindTexture 是否覆盖活动纹理单元的内容
- python - 如何从包含表单应用程序条目值的字典中获取值
- python - Python:“numpy.float64”对象不可调用
- c# - System.Xml.Linq.XContainer.Element(...) 在尝试将 XML 文件加载到 ListView 时返回 null
- python - 尝试 - except 子句,NoSuchElementExcepts 错误