Results 1 to 1 of 1

Thread: problem Extracting Data using HTML Object Library

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    problem Extracting Data using HTML Object Library

    Hi all i am working on project that needs to extract artistname,albumname,... from a music page. As u see in the pic the artistname and albumname are missing and also albuminfo is placed under incorect column. Could an expert help me fix these problems. I enclused the copy of project and html page.Thanks







    VB Code:
    1. Private Sub Form_Load()
    2.     WebBrowser1.Navigate "c:/page2.html"
    3.    
    4. End Sub
    5.  
    6. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    7.     If (pDisp Is WebBrowser1.Application) Then
    8.         GetInfo WebBrowser1.Document
    9.     End If
    10. End Sub
    11.  
    12.  
    13. Private Sub GetInfo(HTML As HTMLDocument)
    14.     Dim HTMLA As HTMLAnchorElement
    15.     Dim HTMLT As HTMLTable
    16.     Dim HTMLR As HTMLTableRow
    17.     Dim HTMLC As HTMLTableCell
    18.     Dim HTMLI As HTMLInputElement
    19.     Dim pTYPE As Integer
    20.     Dim TMP() As String
    21.     Dim tArtist As String
    22.     Dim LI As ListItem
    23.     For Each HTMLT In HTML.getElementsByTagName("table")
    24.         For Each HTMLR In HTMLT.rows
    25.             For Each HTMLC In HTMLR.cells
    26.                 If HTMLC.colSpan = 5 Then
    27.                     tArtist = HTMLC.innerText
    28.                     pTYPE = 1
    29.                 End If
    30.                 If pTYPE = 1 Then
    31.                     For Each HTMLI In HTMLC.getElementsByTagName("input")
    32.                         If HTMLI.Type = "checkbox" Then
    33.                             Set LI = ListView1.ListItems.Add(, "ID:" & HTMLI.Value, HTMLI.Value)
    34.                         End If
    35.                     Next
    36.                     For Each HTMLA In HTMLC.getElementsByTagName("a")
    37.                         If InStr(HTMLA.onclick, LI.Text) Then
    38.                             LI.ListSubItems.Add , , HTMLA.innerText
    39.                             LI.ListSubItems.Add , , tArtist
    40.                             Exit For
    41.                         End If
    42.                     Next
    43.                 Else
    44.                     For Each HTMLA In HTMLC.getElementsByTagName("a")
    45.                         If InStr(HTMLA.href, "WriteLyrics.asp?SongID=") Then
    46.                             TMP = Split(HTMLA.href, "=")
    47.                             If Not LIExists(Replace(TMP(1), "&Singer", "")) Then
    48.                                 Set LI = ListView1.ListItems.Add(, "ID:" & Replace(TMP(1), "&Singer", ""), Replace(TMP(1), "&Singer", ""))
    49.                                 LI.ListSubItems.Add , , TMP(4)
    50.                                 LI.ListSubItems.Add , , Replace(TMP(2), "&Album", "")
    51.                                 LI.ListSubItems.Add , , Replace(TMP(3), "&Song", "")
    52.                             End If
    53.                         End If
    54.                     Next
    55.                 End If
    56.             Next
    57.         Next
    58.     Next
    59.    
    60.    
    61. End Sub
    62. Private Function LIExists(sKEY As String) As Boolean
    63.     On Error GoTo ItsNotThere
    64.     Dim LI2 As ListItem
    65.     Set LI2 = ListView1.ListItems("ID:" & sKEY)
    66.     LIExists = True
    67.    
    68.     Exit Function
    69. ItsNotThere:
    70. End Function
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width