用XMLHTTP很好的一个例子(原创)

类别:Asp 点击:0 评论:0 推荐:

        虽然ting88没有注册的用户不能下载歌曲,但搞定它也非难事啊:)

        进入www.ting88.com的网站,把歌手专辑页面的URL复制到文本框中再提交就可以得到歌曲的下载路径,如:http://www.ting88.com/MusicList/4141.htm

        源程序如下:

<%
on error resume next
dim id,url,getCode,m,i,j,s,d,ns,nd,num,name
id=trim(request.querystring("id"))
'1.获取原网页所有内容
Function getHTTPPage(url)
 dim http
 set http=Server.createobject("Microsoft.XMLHTTP")
 Http.open "GET",url,false
 Http.send()
 if Http.readystate<>4 then
  exit function
 end if
 getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
 set http=nothing
 if err.number<>0 then err.Clear 
End function

'2.编码转换
Function BytesToBstr(body,Cset)
 dim objstream
 set objstream = Server.CreateObject("adodb.stream")
 objstream.Type = 1
 objstream.Mode =3
 objstream.Open
 objstream.Write body
 objstream.Position = 0
 objstream.Type = 2
 objstream.Charset = Cset
 BytesToBstr = objstream.ReadText
 objstream.Close
 set objstream = nothing
End Function

'得到明码URL
function MyReplace(ConvStr)
 ConvStr=replace(ConvStr,"YVI","1")
 ConvStr=replace(ConvStr,"ESR","2")
 ConvStr=replace(ConvStr,"SXN","3")
 ConvStr=replace(ConvStr,"STI","4")
 ConvStr=replace(ConvStr,"WFU","5")
 ConvStr=replace(ConvStr,"LQU","6")
 ConvStr=replace(ConvStr,"QGI","7")
 ConvStr=replace(ConvStr,"BLA","8")
 ConvStr=replace(ConvStr,"JFU","9")
 ConvStr=replace(ConvStr,"LSN","0")
 ConvStr=replace(ConvStr,"XPG","/")
 ConvStr=replace(ConvStr,"XQD",".")
 ConvStr=replace(ConvStr," ","")
 ConvStr=replace(ConvStr,"%20","")
 ConvStr=replace(ConvStr,"KWD","Wma")
 MyReplace=ConvStr
end function

if id="1" then
 url=trim(request.form("txturl"))
 if url="" then
  response.redirect("GetMusic.asp")
  response.end()
 end if
 'url="http://www.ting88.com/MusicList/1454.htm"
 s=0
 d=0
 ns=0
 nd=0
 getCode=getHTTPPage(url)
 num=mid(getCode,instrrev(getCode,".<a href")-3,2)  '获取歌曲的数目
 name=mid(getCode,instr(getCode,"歌手姓名:")+5,10)  '获取歌手
        m="http://218.75.78.189/33445566/"
 response.write "<center>该面页共找到 " & name & "的 <font color=red>" & num& "</font> 首歌曲" & "<br/><br/>"
 response.write "<table width='80%'  border='1' bordercolor='#A4C8FF' cellpadding='0' cellspacing='0'><tr><td>页面

本文地址:http://com.8s8s.com/it/it7465.htm