用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>
猜你喜欢
- CSS Sprites技术不新鲜,早在2005年 CSS Zengarden 的园主 Dave Shea 就在 ALA
- 什么是.netMicrosoft® .NET 是 Microsoft XML Web services 平台。XML Web
- 前段时间在网上找了一个“完美的”JavaScript对象克隆的函数,感觉还不错,但随后便出现了一些问题,发现这个克隆并不好用,在使用发现了如
- 很多朋友想用SQL2000数据库的编程方法,但是却又苦于自己是学ACCESS的,对SQL只是一点点的了解而已,这里我给大家提供以下参考---
- Function getIpvalue(clientIP)'得到客户端的IP转换成长整型,返回值getIpvalue&nb
- 桥接模式(Bridge Pattern)是什么桥接模式是一种结构型模式,它将抽象部分与实现部分分离开来,使它们可以独立地变化。在桥接模式中,
- WEB程序员的技能要求: Web程序员不光要对 后端程序(如 php,jsp,asp.net)语言知识,对程序设计架构知识,数据库
- 在MySQL中,对于索引的使用并是一直都采用正确的决定。简单表的示例:CREATE TABLE `r2` (ID` int(11) DEFA
- Check In/Out功能简介:该功能是专门针对多用户管理而预设的。即多用户使用多帐号管理同一站点。
- 一、MySQL修改密码方法总结首先要说明一点的是:一般情况下,修改MySQL密码是需要有mysql里的root权限的,这样一般用户是无法更改
- 矛盾出来了,像我们这些小作坊,基本都是设计布局一人搞定。甚至还有加后台程序的。假设设计的时候考虑布局了,我们都有这个能力进行调整。但像大公司
- JavaScript 代码一般最常见的语法格式就是定义函数 function xxx(){/*code...*/},经常有这样的一大堆函数定
- 你不可能随时备份数据,但你的数据丢失时,或者数据库目录中的文件损坏时, 你只能恢复已经备份的文件,而在这之后的插入或更新的数据,就无能为力了
- 1.如果客户端和服务器端的连接需要跨越并通过不可信任的网络,那么就需要使用SSH隧道来加密该连接的通信。2.用set password语句来
- 如何在页面错误时向数据库中添加记录?在ASP中,我在页面中添加了On Error Resume Next错误命令,以消除和避免程序错误。现在
- 关于书写习惯,遵循曾经总结过的风格标准,现在一点都没有变。并且近来翻看高手作品,横向连排似乎在大产品项目中逐渐成为主流,个人认为如此维护效率
- 这些小东西是我在网上看到的就把它记下来了,可能以后会有用的: &nbs
- 不通过数据源名DSN也能访问Access数据库吗?代码如下:<% dim conn &nbs
- 下面这些命令可以在命令行下用isql执行,isql -E -Q "命令",isql.exe
- 本文介绍了网页中插入视频播放的代码全集:有avi格式的视频,mpg格式,smi格式,rm格式,wmv格式,wma格式,Windows Med