用XMLHTTP很好的一个例子

作者:佚名 来源:新云 时间:2008-04-25 10:25:00 

虽然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>页面URL:<a href='" & url & "' target='_blank'>" & url & "</a></td></tr></table><hr width='80%'>"
response.write "<table width='80%' border='0' cellpadding='0' cellspacing='0' bgcolor='#A4C8FF'><tr><td><table border='0' width='100%' cellpadding='2' cellspacing='1'><tr><td align=center bgcolor='#FFFFFF'>序号</td><td align=center bgcolor='#FFFFFF'>歌名</td><td align=center bgcolor='#FFFFFF'>操作</td></tr>"
for i=1 to num
s=instr(i+s,getCode,"checked"" value='")
d=instr(i+d,getCode,"KWD'>")
ns=instr(i+ns,getCode,"word=")
nd=instr(i+nd,getCode,"&inc=")
response.write " <tr><td align=center bgcolor='#FFFFFF'>" & i & "</td><td bgcolor='#FFFFFF'> <a href='" & m & MyReplace(mid(getCode,s+16,d-s-13)) & "'>" & mid(getCode,ns+5,nd-ns-5) & "</a><br/></td><td align=center bgcolor='#FFFFFF'><a href='" & m & MyReplace(mid(getCode,s+16,d-s-13)) & "'>下载</a></td></tr>"
next
response.write "</table></td></tr></table></center>"
end if



%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>获取专辑歌曲的URL地址</title>
</head>
<body>
<form name="form1" method="post" action="GetMusic.asp?id=1">
<table width='80%' border='0' align="center" cellpadding='0' cellspacing='0' bgcolor='#A4C8FF'>
<tr><td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<td height="30">获取专辑歌曲的URL地址</td>
</tr>
<tr>
<td height="30" bgcolor="#FFFFFF">网页地址:
<input name="txturl" type="text" id="txturl" size="80" maxlength="100"></td>
</tr>
<tr>
<td height="30" bgcolor="#FFFFFF"> <input type="submit" name="Submit" value="提 交" style="width:60">
<input name="Reset" type="reset" id="Reset" value="重 置" style="width:60"></td>
</tr>
</table></td></tr></table>
</form>
</body>
</html>

标签:
0
投稿

猜你喜欢

  • Python中return函数返回值实例用法

    2023-11-19 02:11:36
  • Go 实现HTTP中间人代理的操作

    2024-04-23 09:40:15
  • 在Python的while循环中使用else以及循环嵌套的用法

    2022-10-18 19:17:14
  • django queryset 去重 .distinct()说明

    2022-10-12 01:01:00
  • Python实现粒子群算法的示例

    2021-06-08 17:34:02
  • 一篇文章教你用Python实现一个学生管理系统

    2022-01-22 16:25:05
  • 出现“不能执行已释放的Script代码”错误的原因及解决办法

    2024-04-19 10:02:13
  • pytorch_detach 切断网络反传方式

    2022-09-25 21:10:50
  • MySQL中事务概念的简洁学习教程

    2024-01-15 18:05:46
  • 利用FrontPage 2003制作网络申请系统

    2008-02-21 14:34:00
  • JS简单的轮播的图片滚动实例

    2024-03-19 19:46:31
  • 利用Python matplotlib绘制风能玫瑰图

    2023-10-12 23:07:24
  • 理想高通滤波实现Python opencv示例

    2022-09-29 03:58:07
  • 详解Linux下安装php环境并且配置Nginx支持php-fpm模块

    2023-11-11 02:02:50
  • 对设计文档的一点小看法

    2010-03-15 12:30:00
  • tensorflow基于CNN实战mnist手写识别(小白必看)

    2021-01-26 22:33:42
  • python+selenium实现简历自动刷新的示例代码

    2023-11-27 16:13:01
  • Python函数式编程指南:对生成器全面讲解

    2022-09-26 05:56:17
  • JS CSS制作饱含热情的镶边文字闪烁特效

    2024-04-16 09:04:51
  • Python装饰器使用方法全面梳理

    2023-04-27 08:22:15
  • asp之家 网络编程 m.aspxhome.com