DEMO地址:http://www.jjad168.cn/111.exe注明:下载部分我没写,相信也很容易给出主要代码,关键是百度歌曲地址加密那一块绕了我一下。 Private Sub Command1_Click() Wmp.URL = "http://mp3.baidu.com/u?u=" & ListView1.SelectedItem.SubItems(ListView1.SelectedItem.Index) End SubPrivate Sub Command3_Click() Me.ListView1.ListItems.Clear paa = Text1.Text Command3.Enabled = FalseDim arrtemp() As String, arrtemp2() As String, aa As String, i As Integer Dim gm As String, gs As String, wz As String, gsi As String aa = Trim(Inet1.OpenURL("http://mp3.baidu.com/m?f=ms&tn=baidump3&ct=134217728&lf=&rn=&word=" & Text1.Text & "&lm=-1"))aa = strCut(aa, "<table border=0 cellpadding=0 cellspacing=0 id=Tbs rules=rows>", "<table width=100% border=0 cellpadding=2 cellspacing=0>")arrtemp = Split(aa, "</tr><tr>")For i = 1 To UBound(arrtemp) - 1gm = strCut(arrtemp(i), "<td class=d>", "</td>") gm = GetMsg(gm) arrtemp2 = Split(arrtemp(i), "</td>") gsi = GetMsg(arrtemp2(UBound(arrtemp2) - 2))wz = strCut(arrtemp(i), "http://", """")wz = strCut(wz, "http://", ",,") wz = "http://" & wzgs = strCut(arrtemp(i), "<td><a href=""", "/a>") gs = strCut(gs, ">", "<") Set addLVW = Me.ListView1.ListItems.Add(, , gm, , tb) addLVW.SubItems(1) = gs addLVW.SubItems(2) = gsi addLVW.SubItems(3) = wzNext iCommand3.Enabled = True End SubPrivate Sub Form_Load() 'livsview设置 With Me.ListView1 .ColumnHeaders.Add = "歌曲名" .ColumnHeaders.Add = "歌手" .ColumnHeaders.Add = "格式" .ColumnHeaders.Add = "网址"
.ColumnHeaders(1).Width = 5000 .ColumnHeaders(2).Width = 2000 .ColumnHeaders(3).Width = 800 .ColumnHeaders(4).Width = 0End With End SubPrivate Sub Form_Unload(Cancel As Integer) End End SubPrivate Sub ListView1_DblClick() Wmp.URL = "http://mp3.baidu.com/u?u=" & ListView1.SelectedItem.SubItems(3)End Sub
WebBrowser1.Navigate "http://mp3.baidu.com/m?tn=baidump3&ct=134217728&lm=-1&word=" & "我的祖国"
End Sub
你做这个东西接近一个简单的元搜索引擎了
<tr>
<td class=tdn>1</td>
<td class=d><a href="http://220.181.38.82/m?ct=134217728&tn=baidusg,回头太难 &word=wma,http://www.xjlove5.net/ewebeditor/uploadfile/Y2Jja2xobWpjZGRpbG1obzE$.wma,,[%BB%D8%CD%B7%CC%AB%C4%D1]&si=%BB%D8%CD%B7%CC%AB%C4%D1;;%D5%C5%D1%A7%D3%D1;;33543;;33543&lm=16777216&sgid=1" title="请点击左键!来源网址: http://www.xjlove5.net 请参照百度权利声明使用" onclick="return ow(event,this)" target="_blank"><font color="#c60a00">回头太难</font> </a></td>
<td><a href="http://mp3.baidu.com/singerlist/%D5%C5%D1%A7%D3%D1.html" target="_blank">张学友</a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> <a href="http://mp3.baidu.com/singerlist/.html" target="_blank"></a> </td>
<td class=al><a href="http://mp3.baidu.com/albumlist/%D5%C5%D1%A7%D3%D1;;;;;;%D5%E6%B0%AE.html" target="_blank">真爱</a> </td>
<td><a href="http://box.zhangmen.baidu.com/m?gate=1&ct=134217728&tn=baidumt,回头太难 &word=wma,http://www.xjlove5.net/ewebeditor/uploadfile/Y2Jja2xobWpjZGRpbG1obzE$.wma,,[%BB%D8%CD%B7%CC%AB%C4%D1]&si=%BB%D8%CD%B7%CC%AB%C4%D1;;%D5%C5%D1%A7%D3%D1;;33543;;33543&lm=16777216&mtid=1&d=9" onclick="return ot(event,this,'33543');">试听</a> </td>
<td><a href="http://mp3.baidu.com/m?tn=baidump3lyric&word=%D5%C5%D1%A7%D3%D1+%BB%D8%CD%B7%CC%AB%C4%D1&ct=150994944&lm=-1&lf=3" target="_blank">歌词</a> </td>
<td> <a name="ls" href="http://mp3.baidu.com/tr?url=http://my.12530.com/newchannel/order/600902000001128474/1/2703/2703_zlss/_/_/_/order.htm&sn=1&title=%BB%D8%CD%B7%CC%AB%C4%D1;;%D5%C5%D1%A7%D3%D1" onclick="return or(event,this);">铃声</a> </td>
<td>1.2 M</td>
<td>wma</td>
<td class=spd><img src="http://img.baidu.com/img/mp3/d9.gif"></td>如何得到以上源码的歌名 网址
如果没有,恐怕要自己写个自动机这样的东西来解析html,提取出里面的tag变成自己定义的类
大概的思路就是这样,实现起来有很多细节需要慢慢调整的
至于怎么样解析,建议有空看看《编译原理》,其实html的解析器的状态图不算复杂的了
Private Sub Command1_Click()
Wmp.URL = "http://mp3.baidu.com/u?u=" & ListView1.SelectedItem.SubItems(ListView1.SelectedItem.Index)
End SubPrivate Sub Command3_Click()
Me.ListView1.ListItems.Clear
paa = Text1.Text
Command3.Enabled = FalseDim arrtemp() As String, arrtemp2() As String, aa As String, i As Integer
Dim gm As String, gs As String, wz As String, gsi As String
aa = Trim(Inet1.OpenURL("http://mp3.baidu.com/m?f=ms&tn=baidump3&ct=134217728&lf=&rn=&word=" & Text1.Text & "&lm=-1"))aa = strCut(aa, "<table border=0 cellpadding=0 cellspacing=0 id=Tbs rules=rows>", "<table width=100% border=0 cellpadding=2 cellspacing=0>")arrtemp = Split(aa, "</tr><tr>")For i = 1 To UBound(arrtemp) - 1gm = strCut(arrtemp(i), "<td class=d>", "</td>")
gm = GetMsg(gm)
arrtemp2 = Split(arrtemp(i), "</td>")
gsi = GetMsg(arrtemp2(UBound(arrtemp2) - 2))wz = strCut(arrtemp(i), "http://", """")wz = strCut(wz, "http://", ",,")
wz = "http://" & wzgs = strCut(arrtemp(i), "<td><a href=""", "/a>")
gs = strCut(gs, ">", "<")
Set addLVW = Me.ListView1.ListItems.Add(, , gm, , tb)
addLVW.SubItems(1) = gs
addLVW.SubItems(2) = gsi
addLVW.SubItems(3) = wzNext iCommand3.Enabled = True
End SubPrivate Sub Form_Load()
'livsview设置
With Me.ListView1
.ColumnHeaders.Add = "歌曲名"
.ColumnHeaders.Add = "歌手"
.ColumnHeaders.Add = "格式"
.ColumnHeaders.Add = "网址"
.ColumnHeaders(1).Width = 5000
.ColumnHeaders(2).Width = 2000
.ColumnHeaders(3).Width = 800
.ColumnHeaders(4).Width = 0End With
End SubPrivate Sub Form_Unload(Cancel As Integer)
End
End SubPrivate Sub ListView1_DblClick()
Wmp.URL = "http://mp3.baidu.com/u?u=" & ListView1.SelectedItem.SubItems(3)End Sub