View Full Version : Help extracting dyanamic data from html code


tony007
05-03-2006, 11:39 AM
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:



<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

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


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


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