[Asp] Tian Feng AJAX Baidu music instant audio attachment download

Source: Internet
Author: User

The input name automatically associates with the name.

The background is dimmed when the music address is read.

Synchronize the LRC lyrics,

Users can expand and integrate their own music sites
Screen. width-333) this. width = screen. width-333 "border = 0>

Screen. width-333) this. width = screen. width-333 "border = 0>

Screen. width-333) this. width = screen. width-333 "border = 0>
Mp3.asp
Copy codeThe Code is as follows:
<% @ Language = "vbscript" CodePage = "936" %>
<%
Response. charset = "gb2312"
Set regex = New regexp
Regex. IgnoreCase = True
Regex. Global = True
Songname = unescape (query ("songname "))
Select Case query ("s ")
Case "geturl": echo geturl (songname)
Case "suggest": echo suggest ()
End select

Function geturl (songname)
Page = ajax ("http://mp3.baidu.com/m? F = ms & tn = baidump3 & ct = 134217728 & lf = & rn = & word = "& songname &" & lm = 0 ","","","")
Regex. Pattern = "(http) \ S + \. (mp3 )"
Set urls = regex.exe cute (page)
'For I = 0 To urls. count-1
'Geturl = geturl & (mp3url (urls (I) & "<br/> ")
'Next
Randomize
I = Int (rnd () * urls. count)
If Len (urls (I) <30 Then I = Int (rnd () * urls. count)
Url = mp3url (urls (I ))
Geturl = "<div>" & mplay (url) & "<a href =" "& url &"> right-click and choose Save as target to download a song <a> </div>"
Getlrc (songname)

End Function

Function mp3url (url)
Page = ajax ("http://box.zhangmen.baidu.com/m? Gate = 1 & ct = 134217728 & tn = baidumt, & word = mp3, "& url &" & lm = 16777216 ","","","")
Regex. Pattern = "(http) \ S + \. (mp3 )"
Set urls = regex.exe cute (page)
If urls. count> 0 Then mp3url = urls (2)
End Function

Function mplay (fileUrl)
Echo "<object classid =" "CLSID: 6BF52A52-394A-11d3-B153-00C04F79FAA6" "codebase =" "http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112" "align =" baseline "" standby = "" Loading Microsoft Windows Media Player components... "" type = "" application/x-oleobject "" id = "mediaPlayerObj" "style =" "width: 300px; height: 64px; border: 1px solid # CCCCCC "">"
Echo "<param name =" "url" "value = '" & fileUrl & "'>"
Echo "<param name =" "rate" "value =" "10" ">"
Echo "<param name =" "balance" "value =" "0" ">"
Echo "<param name =" "currentPosition" "value =" "0" ">"
Echo "<param name =" "playCount" "value =" "1" ">"
Echo "<param name =" "autoStart" "value =" "-1" ">"
Echo "<param name =" "volume" "value =" "60" ">"
Echo "<param name =" "currentMarker" "value =" "0">"
Echo "<param name =" "invokeURLs" "value =" "-1" ">"
Echo "<param name =" "stretchToFit" "value =" "-1" ">"
Echo "<param name =" "windowlessVideo" "value =" "0">"
Echo "<param name =" "enabled" "value =" "-1" ">"
Echo "<param name =" "enableContextMenu" "value =" "0">"
Echo "<param name =" "fullScreen" "value =" "0" ">"
Echo "<param name =" "enableErrorDialogs" "value =" 0 ">"
Echo "<embed src =" & fileUrl & "align =" "baseline" "type =" "application/x-mplayer2" "pluginspage =" id =" "mediaPlayerObj" "showcontrols =" 1 "" showpositioncontrols = "" 0 "" showaudiocontrols = "1" "showtracker =" 1 "" showdisplay = "0" showstatusbar = "1" "autosize =" 0 "" showgotobar = "0" "showcaptioning =" 0 "" autostart = "1" "autorewind =" "0" "animationatstart =" "0" "transparentatstart =" "0" "allowscan =" 1 "" enablecontextmenu = "" 1 "" clicktoplay = "0" "defaultframe = "" datawindow "" invokeurls = "" 0 "" style = "" width: 300px; height: 68px; border: 1px solid # FF0000 ""> </embed>"
Echo "</object>"
End Function

Sub Getlrc (songname)
Echo "<div id =" "lrcxx" "style =" "display: none" "> </div>"
Echo "<span id =" "lrcdata" ">"
Echo "<! --"
Page = ajax ("http://mp3.baidu.com/m? Tn = baidump3lyric & word = "& songname &" & ct = 150994944 & lm =-1 & lf = 3 ","","","")
If InStr (page, "Sorry, not found")> 0 Then
Echo "no lyrics found"
Lrcurl = ""
Else
Regex. Pattern = "(http: //) \ S + \. (lrc )"
Set lrcs = regex. Execute (page)
Lrcurl = lrcs (0)
If lrcs. count> 0 Then
Echo ajax (lrcurl ,"","","")
Else
Echo "no lyrics found"
End If
End if
Echo "-->"
Echo "</span>"
Echo "<div id =" "bkk" ">"
Echo "<div id =" "lrcstart" "> Lyrics: <a href = "& lrcurl &" target = "" new ""> click to download the LRC lyrics </a> </div>"
Echo "<div id =" "lrcollbox" ">"
Echo "<table id =" "lrcoll" "style =" "position: relative; top: 30px; width: 100%; text-align: center" ">"
Echo "<tr> <td> <div id =" "lrcwt1"> </div> </td> </tr>"
Echo "<tr> <td> <div id =" "lrcwt2"> </div> </td> </tr>"
Echo "<tr> <td> <div id =" "lrcwt3"> </div> </td> </tr>"
Echo "<tr> <td class =" "kong" ">"
Echo "<table border =" "0" "cellspacing =" "0" "cellpadding =" "0">"
Echo "<tr> <td nowrap height =" 30 ""> <span id = "" lrcbox "" style = "" width: 0; ""> </span> </td> </tr>"
Echo "<tr style =" "position: relative; top:-30px; z-index: 6; ""> <td nowrap height = "" 30 ""> <span id = "" lrcbc "" style = "" overflow: hidden; width: 0; ""> </span> </td>"
Echo "</tr>"
Echo "</table>"
Echo "</td> </tr>"
Echo "<tr style =" "position: relative; top:-30px; ""> <td> <div id = "" lrcwt4 "> </div> </td> </tr>"
Echo "<tr style =" "position: relative; top:-30px; ""> <td> <div id = "" lrcwt5 "> </div> </td> </tr>"
Echo "</table>"
Echo "</div>"
Echo "</div>"
End Sub

Function Suggest ()
If Trim (query ("songname") <> "then
Songname = Replace (query ("songname ")),"! "," % ")
'Suggest = ajax ("http://mp3.sogou.com/suggest/suggest.jsp? Key = "& escape (query (" songname ") &" & asc = 1 "," UTF-8 ")
Suggest = ajax ("http://music.soso.com/wh.php? "& Songname ,"","","")
End if
End Function

Function Query (byval var)
Query = request. form (var)
If Query = "" then Query = request (var)
End Function

Function Echo (byval str)
Response. write str
End Function


Public Function AJAX (url, method, data, bm)
If method = "" Then method = "get"
If bm = "" Then bm = "gb2312"
Dim http
Set http = Server. createobject ("Microsoft. XMLHTTP ")
Http. open method, url, false
If LCase (method) = "post" then
Http. setrequestheader "content-length", len (data)
Http. setrequestheader "content-type", "application/x-www-form-urlencoded"
End if
Http. send (data)
If Http. readystate = 4 and Http. status = 200 then
AJAX = bytesToBSTR (Http. responseBody, "GB2312 ")
End If
Set http = nothing
End function

Public Function BytesToBstr (body, Cset)
Dim objstream
Set objstream = Server. CreateObject ("ADODB" + "." + "Stream ")
With objstream
. Type = 1
. Mode = 3
. Open
. Write body
. Position = 0
. Type = 2
. Charset = Cset
BytesToBstr =. ReadText
. Close
End
Set objstream = nothing
End Function

Set regex = Nothing
%>

Online Demo http://www.jb51.net/demo/mp4/index.html
Local download

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.