[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

HTA版歌曲免费下载Ver1.0

程序说明:可以从一歌曲网站下载 闽南语 歌曲
使用说明:将以下代码保存为[filename].hta
  1. <!--////////程序说明/////////====
  2. 程序名称:歌曲免费下载Ver1.0(20070810-20070813).hta
  3. 作者说明:youxi01,,,版权没有,欢迎盗版!!///////////-->
  4. <!--///////设置题头,编码方式//////-->
  5. <TITLE>歌曲下载hta版</TITLE>
  6. <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
  7. <!--///////hta标志//////-->
  8. <HTA:APPLICATION
  9. SCROLL="no"
  10. CAPTION="yes"
  11. SYSMENU="yes"/>
  12. <!--///////控制程序部分//////-->
  13. <script language="vbscript">
  14. on error resume next
  15. set http=createobject("Msxml2.ServerXMLHTTP")
  16. set fso=createobject("Scripting.FileSystemObject")
  17. set aso=createobject("ADODB.Stream")
  18. '///////////////////定义自身大小、位置////////
  19. Sub Window_onLoad
  20. window.resizeTo 638,510                        '设置自身大小、位置;
  21. window.moveTo 200,100   
  22. str="请在下面的框中输入某一音乐列表网页(MTV1000音乐网),如:http://www.mtv1000.com/musiclist/3667.html"
  23. top_info.innertext=str
  24. End Sub
  25. '/////////////////添加项目/////////////////
  26. Function addRow(name,addr)
  27. set newrow = mytable.insertRow()
  28. newrow.className="row_add"
  29. newrow.onmouseover=getRef("change_bgcolor")
  30. newrow.onmouseout=getRef("back_bgcolor")
  31. for i=0 to 4        
  32.   newrow.insertCell()
  33. next
  34. newrow.cells(0).innerhtml="<input type=checkbox>"
  35. newrow.cells(1).innerhtml=name
  36. newrow.cells(2).innerhtml=addr
  37. newrow.cells(3).innerhtml="<input type=submit value='试听' class='button_add' onclick=play_music>"
  38. newrow.cells(4).innerhtml="<input type=submit value='下载' class='button_add' onclick=addbt_click>"
  39. End Function
  40. '///////////////改变对象背景//////////////
  41. Function change_bgcolor()
  42.   me.className="new_row_add"
  43.   me.cells(3).children(0).style.backgroundcolor="#ccd2ad"
  44.   me.cells(4).children(0).style.backgroundcolor="#ccd2ad"
  45. End Function
  46. '/////////////返回原来背景色//////////////
  47. Function back_bgcolor()
  48.   me.className="row_add"
  49.   me.cells(3).children(0).style.backgroundcolor="#ccd2de"
  50.   me.cells(4).children(0).style.backgroundcolor="#ccd2de"
  51. End Function
  52. '//////////////连接某网页///////////////
  53. Function connect_url(url)
  54. http.open "GET",url,true  '发送网页地址;
  55. http.send
  56. for i=1 to 10
  57.     top_info.innertext="正在连接"&url
  58.     if http.readystate=4 then exit for
  59.     http.waitForResponse(500)
  60. next
  61. if http.readystate<>4 then
  62.    top_info.innertext="连接"&url&"失败..."
  63.    http.abort
  64.    exit function
  65. end if
  66. top_info.innertext="连接"&url&"成功..."
  67. connect_url=true
  68. End Function
  69. '/////////////////////转化数据格式////////////////
  70. Function bytes2str(url)
  71. if connect_url(url)<>true then Exit function
  72. vIn=http.ResponseBody            '变量接收传回的数据
  73. bytes2str=""
  74. For i = 1 To LenB(vIn)           '以下代码处理数据类型
  75.   ThisCharCode = AscB(MidB(vIn,i,1))
  76.   If ThisCharCode < &H80 Then
  77.      bytes2str=bytes2str & Chr(ThisCharCode)
  78.   Else           '汉字占两个字节               
  79.      NextCharCode = AscB(MidB(vIn,i+1,1))         
  80.      bytes2str=bytes2str & Chr(CLng(ThisCharCode) * &H100 + CInt (NextCharCode))
  81.      i = i + 1
  82.   End If
  83. Next
  84. End Function
  85. '/////////////提取音乐文件列表/////////////
  86. Function pickup_musiclist(url)
  87. strReturn=bytes2str(url)        
  88. Pos1=instr(strReturn,"歌曲名字")       '从传回结果查询特定字符;
  89. Pos2=instr(strReturn,"全选")
  90. StrLen=Pos2-Pos1
  91. ResStr=mid(strReturn,Pos1,StrLen)      '取这两个字符串之间的内容,只有这些内容才有用;
  92. do
  93.   PathPos=instr(ResStr,"rel")          '根据特定字符来找有用信息(文件名和路径在它们旁边);
  94.   if PathPos>0 then                    '如果还能找到'rel',执行下面的代码;
  95.       MusicPath=mid(ResStr,PathPos-20,18)      '文件路径
  96.       MusicPath=replace(MusicPath,chr(34),"")
  97.       NamePos1=instr(ResStr,"</a>")
  98.       NamePos2=instr(ResStr,"</a></li></ul>")
  99.       Slen=NamePos1-PathPos-15                 '文件名长度
  100.       MusicName=mid(ResStr,PathPos+15,Slen)    '文件名称;
  101.       ResStr=mid(ResStr,NamePos2+12)
  102.    else
  103.       exit do
  104.    end if           
  105.    addRow MusicName,MusicPath
  106. loop
  107. End Function
  108. '/////////////获得文件真实地址/////////
  109. Function get_musicurl(url)
  110. strReturn=bytes2str(url)
  111. OBJPos1=instr(strReturn,"player(")     '根据特征字符,找出音乐文件真正地址;        
  112. OBJPos2=instr(strReturn,"wma")
  113. if OBJPos2<1 then OBJPos2=instr(strReturn,"Wma")
  114. OBJLen=OBJPos2-OBJPos1-5
  115. get_musicurl=mid(strReturn,OBJPos1+8,OBJLen)
  116. End Function
  117. '////////////////////下载对应文件////////////
  118. Function download_file(url,name)
  119. if fso.fileexists(name&".wma") then '判断要下载的文件是否已经存在'
  120.     start=fso.getfile(name&".wma").size '存在,以当前文件大小作为开始位置'
  121. else
  122.     start=0 '不存在,一切从零开始'
  123.     fso.createtextfile(name&".wma").close '新建文件'
  124. end if
  125. current=start
  126. str="正在下载文件: "&name&".wma"
  127. top_info.innertext=str
  128. fileurl=get_musicurl("http://www.mtv1000.com"&url)
  129. do
  130. http.open "GET","http://t.mtv1000.com:81"&fileurl,true
  131. http.setRequestHeader "Content-Type","application/octet-stream"
  132. http.setrequestheader "Range","bytes="&start&"-"&cstr(start+20480)
  133. http.send        
  134. for i=1 to 120                        
  135.     if http.readystate=4 then exit for
  136.     http.waitForResponse(500)
  137. next
  138. If http.status=416 Then Exit do
  139. aso.type=1
  140. aso.open
  141. aso.loadfromfile name&".wma"        
  142. aso.position=start
  143. aso.write http.responsebody
  144. aso.savetofile name&".wma",2
  145. aso.close
  146. range=http.getresponseheader("Content-Range")        '获得http头中的"Content-Range"'
  147. temp=mid(range,instr(range,"-")+1)
  148. current=clng(left(temp,instr(temp,"/")-1))           '当前已下载大小(字节)
  149. total=clng(mid(temp,instr(temp,"/")+1))              '文件总大小
  150. if total-current=1 then exit do                      '下载完成;
  151. start=start+20480                                    '再下载20KB
  152. progress="   进度:"&cint(current/total*100)&"%"
  153. finish="  完成:"&cint(current/1024)&"/"&cint(total/1024)&" KB"
  154. top_info.innertext=str&finish&progress
  155. loop while true
  156. top_info.innertext=name&".wma 已经下载完毕!"
  157. End Function
  158. '//////////////全部选择///////////////
  159. Function select_all()
  160. if bt1.value="全部选择" then
  161.    for i=1 to mytable.rows.length-1
  162.      mytable.rows(i).cells(0).children(0).checked=true
  163.    next
  164.    bt1.value="全不选择"
  165. else
  166.    for i=1 to mytable.rows.length-1
  167.      mytable.rows(i).cells(0).children(0).checked=false
  168.    next
  169.    bt1.value="全部选择"
  170. end if
  171. End Function
  172. Sub bt3_onclick()
  173. for i=1 to mytable.rows.length-1
  174.    if mytable.rows(i).cells(0).children(0).checked=true then
  175.        mp=mytable.rows(i).cells(2).innertext
  176.        mn=mytable.rows(i).cells(1).innertext
  177.        download_file mp,mn
  178.    end if
  179. next
  180. End Sub
  181. '////////////////////删除选项/////////////
  182. Function del_row()
  183. num=mytable.rows.length-1  
  184. for i=num to 1 step -1
  185.   if mytable.rows(i).cells(0).children(0).checked=true then
  186.       mytable.deleterow(i)
  187.   end if
  188. next
  189. End Function
  190. Function addbt_click()
  191. set objrow=window.event.srcElement.parentelement.parentelement
  192. mn=objrow.cells(1).innertext
  193. mp=objrow.cells(2).innertext
  194. download_file mp,mn
  195. End Function
  196. Function play_music()
  197. set objrow=window.event.srcElement.parentelement.parentelement
  198. mn=objrow.cells(1).innertext
  199. mp=objrow.cells(2).innertext
  200. name=get_musicurl("http://www.mtv1000.com"&mp)
  201. top_info.innertext="正在试听:"&mn
  202. str=str&"<object classid='clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95' height='25' width='170'>"
  203. str=str&"<param name='Filename' value='http://t.mtv1000.com:81"&name&"'>"
  204. str=str&"<param name='AutoStart' value='1'>"
  205. str=str&"<param name='ClickToPlay' value='1'>"
  206. str=str&"</object>"
  207. play_themusic.innerhtml=str
  208. End Function
  209. '/////////////退出程序/////////////
  210. Sub window_onunload
  211. set fso=nothing
  212. set aso=nothing
  213. set http=nothing
  214. End Sub
  215. </script>
  216. <style>
  217. #total_container{border:1px solid #000069;
  218.                  width:600px;
  219.                  text-align:center;
  220.                  padding:2px;
  221.                  height:400px;}
  222. #title{width:598px;
  223.       text-align:center;
  224.       font-family: "隶书";
  225.       font-size: 24px;
  226.       font-weight: bold;
  227.       background: #EEE;
  228.       margin:1px;}
  229. #top_info{
  230.       height:16px;
  231.       text-align:center;
  232.       font-family: "隶书";
  233.       font-size: 12px;
  234.       color:red;
  235.       line-height:16px; }
  236. #main_container{width:600px;
  237.                 height:300px;
  238.                 background: #EEE;
  239.                 border:1px solid #000069;
  240.                 overflow:auto;}
  241. #musicaddr_container{width:600px;
  242.                      height:25px;
  243.                      background: #EEE;
  244.                      border:0px;
  245.                      padding:2px 2px;}
  246. #play_themusic{width:600px;
  247.             height:26px;
  248.             text-align:center;
  249.             line-height:26px;}
  250. #foot_container{width:600px;
  251.                 height:30px;
  252.                 border:1px solid #000069;
  253.                 padding:2px 2px;}
  254. .text{text-align:center;
  255.       font-size:12px;
  256.       color:red;}
  257. .separate_line{border:1px solid white;
  258.                height:1px;
  259.                width:600px;}
  260. .button_container{text-align:center;
  261.                   float:left;
  262.                   width:146px;
  263.                   border:1px solid #ccc;
  264.                   background-color:#F3F3F3;
  265.                   font-size:12px;
  266.                   color:#333333;
  267.                   padding:2px 2px;
  268.                   margin=1px;
  269.                   line-height:20px;}
  270. .button_self{text-align:center;
  271.              border:0;
  272.              background-color:#eee;
  273.              height:100%;
  274.              cursor:pointer}
  275. .button_add{text-align:center;
  276.              border:0;
  277.              background-color:#ccd2de;
  278.              height:100%;
  279.              cursor:pointer}
  280. .table_th{text-align=center;
  281.           background-color:#006699;
  282.           font-size:14px;
  283.           font-family: "隶书";
  284.           color:#F2F3F7;
  285.           padding:2px;
  286.           line-height:22px;}
  287. .row_add{text-align:center;
  288.          background-color:#ccd2de;
  289.          height:4px;
  290.          font-size:12px;
  291.          line-height:15px;
  292.          padding:2px;}
  293. .new_row_add{text-align:center;
  294.              color:red;
  295.              background-color:#ccd2ad;
  296.              height:4px;
  297.              font-size:12px;
  298.              line-height:15px;
  299.              padding:2px;}
  300. </style>
  301. <!--///////以下为要显示对象/////////////-->
  302. <div id="total_container">
  303. <div id="title">歌曲免费下载</div>
  304. <div id="top_info">欢迎使用</div>
  305. <div id="musicaddr_container">
  306.     <input type=text size=40 value="http://www.mtv1000.com/musiclist/3667.html" id="music_addr" onmouseover="music_addr.select()" id="music_addr">
  307.     <input type=button value="点击获取" class="button_self" onclick="pickup_musiclist(music_addr.value)" ID="geturl"></div>
  308. <hr class="separate_line">
  309. <div id="main_container">
  310.   <table border=0 width=100% ID="mytable">
  311.   <tr class="table_th"><th>选定</th><th>歌曲名称</th><th>歌曲所在网页</th><th>歌曲试听</th><th>歌曲下载</th>
  312.   </table>
  313. </div>
  314. <div id="play_themusic">欢迎使用</div>
  315. <div id="foot_container">
  316.   <div class="button_container"><input type=submit value="全部选择" class="button_self"  ID="bt1" onclick=select_all></div>
  317.   <div class="button_container"><input type=submit value="删除选定" class="button_self"  ID="bt2" onclick=del_row></div>
  318.   <div class="button_container"><input type=submit value="下载选定" class="button_self" id="bt3"></div>
  319.   <div class="button_container"><input type=submit value="退出程序" class="button_self" onclick=self.close></div>
  320. </div>
  321. </div>
复制代码
附件: 您需要登录才可以下载或查看附件。没有帐号?注册

能不能搞个可以自己选择后缀的?比如RAR.TXT之类.
这些代码都看不懂..

TOP

返回列表