有些网页对真实的mp3地址进行了防盗链处理,造成无法直接查看源文件来获取真实的物理地址。有时他会将地址保存在%USERPROFILE%\Administrator\Local Settings\Temporary Internet Files 下面为html文件,其中就包含了其真实的地址,有时在一个网页内有多个mp3地址,也就会有多个html文件,如果手工一个一个处理相当,下面用 bat+vbs 来提取,其实用findstr也可以。更简单!
bat code:
@echo off
REM code by woyigui
REM dir命令后的htm文件随意修改
for /f "tokens=*" %%i in ('dir /s /b ^"C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files\MusicUrl*.htm^"') do type "%%i" >> d:\mp3plist.txt && echo. >>d:\mp3plist.txt
cscript mp3-url.vbs d:\mp3plist.txt
vbs code:
Dim p,s,re
If Wscript.Arguments.Count=0 Then
Msgbox "请把网页拖到本程序的图标上!",,"提示"
Wscript.Quit
End If
For i= 0 to Wscript.Arguments.Count - 1
p=Wscript.Arguments(i)
With CreateObject("Adodb.Stream")
.Type=2
.Charset="GB2312"
.Open
.LoadFromFile=p
s=.ReadText
Set re =New RegExp
re.Pattern= "(
http://.*.mp3)"
re.Global = True
If Not re.Test(s) Then
Msgbox "该网页文件中未出现!",,"提示"
Wscript.Quit
End If
Set Matches = re.Execute(s)
s=""
For Each Match In Matches
s=s & Match.Value & vbCrlf
Next
re.Pattern= "&\w+;?|\W{5,}"
s=re.Replace(s,"")
.Position=0
.setEOS
.WriteText s
.SaveToFile p,2
.Close
End With
Next
其中的vbs略加修改,可用于很多需求。最后的结果在:d:\mp3plist.txt 文件中。