Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 3rd, 2006, 03:00 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help extracting dyanamic data from html code

Hi all:

I got a html code that i used inet.openURL to put it in textbox. Now i want to extract Artistname , albumname,songname,artistpic from it. The code already extracts song ids but i want to output songname and other informatin with it. I be happy if an expert show me an easy way to extract those data.Thanks

Note: in one page there is one album for single artist but mutliple songnames
Note: the bold parts are dynamaic and changing and i want extract them

These blocks of html are amoung othe codes that i removed them in mypost
html part that holds each song name:



Code:
<img border="0" src="../images/download.gif" width="16" height="16" longdesc="Download songname" alt="Download songname"></a>
                            &nbsp;songname
                               </td>

Html part that holds artist name and album

Code:
::: Singer: <b>artistname</b> Album <b>albumename</b>::::</td>
Html part tha holdes artist image


Code:
<td>
                  <br>
                  <a href="http://localhost/ShowImage.asp?img=http://localhost/artistpic.jpg" target=_blank>
                  <img border="0" src="../CdImages/artistpic.jpg" width="180" height="180" longdesc="Click here to Enlarge" alt="Click here to Enlarge" >
                  </a>
                </td>



Code:
Private Sub Command1_Click(Index As Integer)

Select Case Index
    Case 0:
        If txtURL.Text <> "" Then
            RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
        End If

    Case 1:
        End
End Select
End Sub


Private Sub Command2_Click()
 Dim sResult() As String, n As Long


            If GetLine(RichTextBox1.Text, "../player/player.asp?id=", "')", sResult)  Then
     For n = LBound(sResult) To UBound(sResult)
          List1.AddItem sResult(n)         
        Next n

Else
        ' No occurances were found
    End If
End Sub




Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String, ByRef sArr() As String) As Boolean
    Dim lPos As Long, lEnd As Long, lCount As Long, sTemp() As String

    ReDim sTemp(100)

    lPos = InStr(1, sText, sStart, vbTextCompare)
    Do While lPos
        lEnd = InStr(lPos, sText, sEnd, vbTextCompare)
        If lEnd Then

            sTemp(lCount) = Mid$(sText, lPos, lEnd - lPos)
            lPos = InStr(lEnd, sText, sStart, vbTextCompare)
        Else
            sTemp(lCount) = Mid$(sText, lPos)
            lPos = 0
        End If
        lCount = lCount + 1
        If lCount > UBound(sTemp) Then ReDim Preserve sTemp(100 + lCount)
    Loop

    If lCount > 0 Then
        ReDim Preserve sTemp(lCount - 1)
        sArr = sTemp
    End If
    GetLine = lCount
End Function





Similar Threads
Thread Thread Starter Forum Replies Last Post
Extracting data from excel spreadsheets Neil1234567 Access VBA 2 October 16th, 2007 07:28 AM
Extracting data from Spreadsheets in a folder IainAL VB How-To 2 April 20th, 2007 02:57 AM
problem Extracting Data using HTML Object Library method VB How-To 0 May 12th, 2006 02:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.