vba从单页web应用程序抓取web

ykejflvf  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(385)

大家好,有人能帮我吗?我必须在输入框中输入一些值,然后单击搜索按钮。根据这一点,inputbox值数据显示在同一页面中,而不更改其url。我编写了一个代码,在inputbox中输入一个值,但当代码单击search按钮时,弹出窗口显示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">

检查元件是否有搜索按钮

<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
wswtfjt7

wswtfjt71#

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

相关问题