程序说明:可以从一歌曲网站下载 闽南语 歌曲
使用说明:将以下代码保存为[filename].hta- <!--////////程序说明/////////====
- 程序名称:歌曲免费下载Ver1.0(20070810-20070813).hta
- 作者说明:youxi01,,,版权没有,欢迎盗版!!///////////-->
- <!--///////设置题头,编码方式//////-->
- <TITLE>歌曲下载hta版</TITLE>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
- <!--///////hta标志//////-->
- <HTA:APPLICATION
- SCROLL="no"
- CAPTION="yes"
- SYSMENU="yes"/>
- <!--///////控制程序部分//////-->
- <script language="vbscript">
- on error resume next
- set http=createobject("Msxml2.ServerXMLHTTP")
- set fso=createobject("Scripting.FileSystemObject")
- set aso=createobject("ADODB.Stream")
- '///////////////////定义自身大小、位置////////
- Sub Window_onLoad
- window.resizeTo 638,510 '设置自身大小、位置;
- window.moveTo 200,100
- str="请在下面的框中输入某一音乐列表网页(MTV1000音乐网),如:http://www.mtv1000.com/musiclist/3667.html"
- top_info.innertext=str
- End Sub
- '/////////////////添加项目/////////////////
- Function addRow(name,addr)
- set newrow = mytable.insertRow()
- newrow.className="row_add"
- newrow.onmouseover=getRef("change_bgcolor")
- newrow.onmouseout=getRef("back_bgcolor")
- for i=0 to 4
- newrow.insertCell()
- next
- newrow.cells(0).innerhtml="<input type=checkbox>"
- newrow.cells(1).innerhtml=name
- newrow.cells(2).innerhtml=addr
- newrow.cells(3).innerhtml="<input type=submit value='试听' class='button_add' onclick=play_music>"
- newrow.cells(4).innerhtml="<input type=submit value='下载' class='button_add' onclick=addbt_click>"
- End Function
- '///////////////改变对象背景//////////////
- Function change_bgcolor()
- me.className="new_row_add"
- me.cells(3).children(0).style.backgroundcolor="#ccd2ad"
- me.cells(4).children(0).style.backgroundcolor="#ccd2ad"
- End Function
- '/////////////返回原来背景色//////////////
- Function back_bgcolor()
- me.className="row_add"
- me.cells(3).children(0).style.backgroundcolor="#ccd2de"
- me.cells(4).children(0).style.backgroundcolor="#ccd2de"
- End Function
- '//////////////连接某网页///////////////
- Function connect_url(url)
- http.open "GET",url,true '发送网页地址;
- http.send
- for i=1 to 10
- top_info.innertext="正在连接"&url
- if http.readystate=4 then exit for
- http.waitForResponse(500)
- next
- if http.readystate<>4 then
- top_info.innertext="连接"&url&"失败..."
- http.abort
- exit function
- end if
- top_info.innertext="连接"&url&"成功..."
- connect_url=true
- End Function
-
- '/////////////////////转化数据格式////////////////
- Function bytes2str(url)
- if connect_url(url)<>true then Exit function
- vIn=http.ResponseBody '变量接收传回的数据
- bytes2str=""
- For i = 1 To LenB(vIn) '以下代码处理数据类型
- ThisCharCode = AscB(MidB(vIn,i,1))
- If ThisCharCode < &H80 Then
- bytes2str=bytes2str & Chr(ThisCharCode)
- Else '汉字占两个字节
- NextCharCode = AscB(MidB(vIn,i+1,1))
- bytes2str=bytes2str & Chr(CLng(ThisCharCode) * &H100 + CInt (NextCharCode))
- i = i + 1
- End If
- Next
- End Function
- '/////////////提取音乐文件列表/////////////
- Function pickup_musiclist(url)
- strReturn=bytes2str(url)
- Pos1=instr(strReturn,"歌曲名字") '从传回结果查询特定字符;
- Pos2=instr(strReturn,"全选")
- StrLen=Pos2-Pos1
- ResStr=mid(strReturn,Pos1,StrLen) '取这两个字符串之间的内容,只有这些内容才有用;
- do
- PathPos=instr(ResStr,"rel") '根据特定字符来找有用信息(文件名和路径在它们旁边);
- if PathPos>0 then '如果还能找到'rel',执行下面的代码;
- MusicPath=mid(ResStr,PathPos-20,18) '文件路径
- MusicPath=replace(MusicPath,chr(34),"")
- NamePos1=instr(ResStr,"</a>")
- NamePos2=instr(ResStr,"</a></li></ul>")
- Slen=NamePos1-PathPos-15 '文件名长度
- MusicName=mid(ResStr,PathPos+15,Slen) '文件名称;
- ResStr=mid(ResStr,NamePos2+12)
- else
- exit do
- end if
- addRow MusicName,MusicPath
- loop
- End Function
- '/////////////获得文件真实地址/////////
- Function get_musicurl(url)
- strReturn=bytes2str(url)
- OBJPos1=instr(strReturn,"player(") '根据特征字符,找出音乐文件真正地址;
- OBJPos2=instr(strReturn,"wma")
- if OBJPos2<1 then OBJPos2=instr(strReturn,"Wma")
- OBJLen=OBJPos2-OBJPos1-5
- get_musicurl=mid(strReturn,OBJPos1+8,OBJLen)
- End Function
-
- '////////////////////下载对应文件////////////
- Function download_file(url,name)
- if fso.fileexists(name&".wma") then '判断要下载的文件是否已经存在'
- start=fso.getfile(name&".wma").size '存在,以当前文件大小作为开始位置'
- else
- start=0 '不存在,一切从零开始'
- fso.createtextfile(name&".wma").close '新建文件'
- end if
-
- current=start
- str="正在下载文件: "&name&".wma"
- top_info.innertext=str
- fileurl=get_musicurl("http://www.mtv1000.com"&url)
- do
- http.open "GET","http://t.mtv1000.com:81"&fileurl,true
- http.setRequestHeader "Content-Type","application/octet-stream"
- http.setrequestheader "Range","bytes="&start&"-"&cstr(start+20480)
- http.send
-
- for i=1 to 120
- if http.readystate=4 then exit for
- http.waitForResponse(500)
- next
-
- If http.status=416 Then Exit do
- aso.type=1
- aso.open
- aso.loadfromfile name&".wma"
- aso.position=start
- aso.write http.responsebody
- aso.savetofile name&".wma",2
- aso.close
-
- range=http.getresponseheader("Content-Range") '获得http头中的"Content-Range"'
- temp=mid(range,instr(range,"-")+1)
- current=clng(left(temp,instr(temp,"/")-1)) '当前已下载大小(字节)
- total=clng(mid(temp,instr(temp,"/")+1)) '文件总大小
- if total-current=1 then exit do '下载完成;
- start=start+20480 '再下载20KB
-
- progress=" 进度:"&cint(current/total*100)&"%"
- finish=" 完成:"&cint(current/1024)&"/"&cint(total/1024)&" KB"
- top_info.innertext=str&finish&progress
- loop while true
- top_info.innertext=name&".wma 已经下载完毕!"
- End Function
- '//////////////全部选择///////////////
- Function select_all()
- if bt1.value="全部选择" then
- for i=1 to mytable.rows.length-1
- mytable.rows(i).cells(0).children(0).checked=true
- next
- bt1.value="全不选择"
- else
- for i=1 to mytable.rows.length-1
- mytable.rows(i).cells(0).children(0).checked=false
- next
- bt1.value="全部选择"
- end if
- End Function
- Sub bt3_onclick()
- for i=1 to mytable.rows.length-1
- if mytable.rows(i).cells(0).children(0).checked=true then
- mp=mytable.rows(i).cells(2).innertext
- mn=mytable.rows(i).cells(1).innertext
- download_file mp,mn
- end if
- next
- End Sub
-
- '////////////////////删除选项/////////////
- Function del_row()
- num=mytable.rows.length-1
- for i=num to 1 step -1
- if mytable.rows(i).cells(0).children(0).checked=true then
- mytable.deleterow(i)
- end if
- next
- End Function
-
- Function addbt_click()
- set objrow=window.event.srcElement.parentelement.parentelement
- mn=objrow.cells(1).innertext
- mp=objrow.cells(2).innertext
- download_file mp,mn
- End Function
-
- Function play_music()
- set objrow=window.event.srcElement.parentelement.parentelement
- mn=objrow.cells(1).innertext
- mp=objrow.cells(2).innertext
- name=get_musicurl("http://www.mtv1000.com"&mp)
- top_info.innertext="正在试听:"&mn
- str=str&"<object classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' height='25' width='170'>"
- str=str&"<param name='Filename' value='http://t.mtv1000.com:81"&name&"'>"
- str=str&"<param name='AutoStart' value='1'>"
- str=str&"<param name='ClickToPlay' value='1'>"
- str=str&"</object>"
- play_themusic.innerhtml=str
- End Function
- '/////////////退出程序/////////////
- Sub window_onunload
- set fso=nothing
- set aso=nothing
- set http=nothing
- End Sub
- </script>
- <style>
- #total_container{border:1px solid #000069;
- width:600px;
- text-align:center;
- padding:2px;
- height:400px;}
- #title{width:598px;
- text-align:center;
- font-family: "隶书";
- font-size: 24px;
- font-weight: bold;
- background: #EEE;
- margin:1px;}
- #top_info{
- height:16px;
- text-align:center;
- font-family: "隶书";
- font-size: 12px;
- color:red;
- line-height:16px; }
- #main_container{width:600px;
- height:300px;
- background: #EEE;
- border:1px solid #000069;
- overflow:auto;}
- #musicaddr_container{width:600px;
- height:25px;
- background: #EEE;
- border:0px;
- padding:2px 2px;}
- #play_themusic{width:600px;
- height:26px;
- text-align:center;
- line-height:26px;}
- #foot_container{width:600px;
- height:30px;
- border:1px solid #000069;
- padding:2px 2px;}
- .text{text-align:center;
- font-size:12px;
- color:red;}
- .separate_line{border:1px solid white;
- height:1px;
- width:600px;}
- .button_container{text-align:center;
- float:left;
- width:146px;
- border:1px solid #ccc;
- background-color:#F3F3F3;
- font-size:12px;
- color:#333333;
- padding:2px 2px;
- margin=1px;
- line-height:20px;}
- .button_self{text-align:center;
- border:0;
- background-color:#eee;
- height:100%;
- cursor:pointer}
- .button_add{text-align:center;
- border:0;
- background-color:#ccd2de;
- height:100%;
- cursor:pointer}
- .table_th{text-align=center;
- background-color:#006699;
- font-size:14px;
- font-family: "隶书";
- color:#F2F3F7;
- padding:2px;
- line-height:22px;}
- .row_add{text-align:center;
- background-color:#ccd2de;
- height:4px;
- font-size:12px;
- line-height:15px;
- padding:2px;}
- .new_row_add{text-align:center;
- color:red;
- background-color:#ccd2ad;
- height:4px;
- font-size:12px;
- line-height:15px;
- padding:2px;}
- </style>
- <!--///////以下为要显示对象/////////////-->
- <div id="total_container">
- <div id="title">歌曲免费下载</div>
- <div id="top_info">欢迎使用</div>
- <div id="musicaddr_container">
- <input type=text size=40 value="http://www.mtv1000.com/musiclist/3667.html" id="music_addr" onmouseover="music_addr.select()" id="music_addr">
- <input type=button value="点击获取" class="button_self" onclick="pickup_musiclist(music_addr.value)" ID="geturl"></div>
- <hr class="separate_line">
- <div id="main_container">
- <table border=0 width=100% ID="mytable">
- <tr class="table_th"><th>选定</th><th>歌曲名称</th><th>歌曲所在网页</th><th>歌曲试听</th><th>歌曲下载</th>
- </table>
- </div>
- <div id="play_themusic">欢迎使用</div>
- <div id="foot_container">
- <div class="button_container"><input type=submit value="全部选择" class="button_self" ID="bt1" onclick=select_all></div>
- <div class="button_container"><input type=submit value="删除选定" class="button_self" ID="bt2" onclick=del_row></div>
- <div class="button_container"><input type=submit value="下载选定" class="button_self" id="bt3"></div>
- <div class="button_container"><input type=submit value="退出程序" class="button_self" onclick=self.close></div>
- </div>
- </div>
复制代码 链接: https://pan.baidu.com/s/1jWu86YQo38vXma7AcF_S7w?pwd=4av1 |