1

ウェブページからデータを取得しようとしています。(いくつかのリンク)

そのウェブページには、お客様から寄せられたチケット(リンク)がたくさんあります。各リンクを調べて、各チケット(リンク)から特定のデータを取得する必要があります。

私のプログラムは、各レビューリンクをクリックして、各リンクからデータを取得する必要があります。

私のプログラムは最初のチケットデータを正常に選択しますが、すべてではありません(最初のリンクをクリックして、最初のリンクデータを正常に取得すると、エラーがスローされます)。

エラー(アクセスエラー)をスローします

申し訳ありませんが私のコードは巨大です

Option Explicit

Sub AVS()
Dim ie As InternetExplorer
Dim iedoc As HTMLDocument
Dim innerString As String
Dim ttext As Integer
Dim avsHtmlTable As Object
Dim links As HTMLAnchorElement
Dim link As Object
Dim lRow As Integer

Set ie = New InternetExplorer
ie.Visible = True
ie.Navigate "https://apj-i.svcs.hp.com/itam-av1/"

Do While ie.Busy
    DoEvents
Loop

Do Until ie.ReadyState = READYSTATE_COMPLETE
    DoEvents
Loop

Set iedoc = ie.Document
With iedoc.forms("Login")
    .all.Item("USER").Value = "Mail id goes here"
    .all.Item("PASSWORD").Value = "pw goes here"
    .submit
End With

Do While ie.Busy
    DoEvents
Loop

Do Until ie.ReadyState = READYSTATE_COMPLETE
    DoEvents
Loop

With iedoc.forms("aspnetForm")
    .all.Item("ctl00$conNavBar$acpAssets_content$btnAssets-ExceptionSearch").Click
End With

Do While ie.Busy
    DoEvents
Loop

Do Until ie.ReadyState = READYSTATE_COMPLETE
    DoEvents
Loop

With iedoc.forms("aspnetForm")
    .all.Item("ctl00$conMainPageContent$txtMaxRows").Value = 100
    .all.Item("ctl00$conMainPageContent$rblStatus").Item(4).Checked = True
    .all.Item("ctl00$conMainPageContent$btnAssetExceptionSearch").Click
End With

Do While ie.Busy
    DoEvents
Loop

Do Until ie.ReadyState = READYSTATE_COMPLETE
    DoEvents
Loop

With iedoc.forms("aspnetForm")
    innerString = .innerText
    ttext = InStr(innerString, "There are no results found for this query")
    If Not ttext = 0 Then
        MsgBox "There are no Tickets are there in AVS - Exception ", vbInformation, "AVS-Exception"
    Else
        ''ctl00_conMainPageContent_grdAssetExceptionSearchResults
        Set avsHtmlTable = iedoc.getElementsByTagName("a")

        For Each link In avsHtmlTable
            If link.innerHTML = "Review" Then
                link.Click
                Do While ie.Busy
                    DoEvents
                Loop
                Do Until ie.ReadyState = READYSTATE_COMPLETE
                    DoEvents
                Loop
                With Sheets("AVS")
                set iedoc=ie.document
                    lRow = .Range("A10000").End(xlUp).Row
                    > ##        ' error throws here
                    Range("A" & lRow).Value = iedoc.getElementById("ctl00_conMainPageContent_ddlAssignment").Value
                End With
            End If
        Next link
    End If
End With

End Sub

申し訳ありませんが..私の最初の投稿のために画像を添付できません。

4

0 に答える 0