今天在优酷里面找一些MV来看,虽然不说里面的视频有高质量,但是还是蛮全的,速度也不错…后来发现想看的视频太多了,一个一个慢慢等缓冲来看慢死了,还是想办法下载吧!
再网上搜索了半天…下载的办法不是从IE缓存里面里面COPY出来(这样的话让IE自己缓冲下载速度太慢了),就是安装那些影音嗅探工具….汗,我的机子里面大多软件都是绿色的了,更加不想安装软件,算了,自己想办法来写一个吧!
开始分析:
首先先在缓存里面查看某个已经缓冲好的FLV视频的name,然后在到这个flv的页面源文件里面是查询这个flv的文件名…一搜索以后果然找到了,哈哈,兴奋啊!距离写程序又近了一步…
确定了源文件里面也有这个flv文件的名字以后猜想:”既然网页的源文件里面都有这个视频的名字,那么就是说这个文件名是没有加密过的,应该可以直接DOWNLOAD了吧”...然后测试一下 www.youku.com/XXX.FLV,靠居然不行,跟着再试 http://v.youku.com/v_show/XXX.FLV ...可恶,居然还不可以...哎,不能放弃啊,距离终点不远了...想了一下,记得缓存文件的属性里边一般都会记录有从哪个URL缓冲过来吧…试试吧…
OK,测试成功,确定优酷的视频是从其他地址传输过来的…好了,该弄明白的都弄明白了,下面开始写程序咯,哈哈
写程序思路:
首先要获取那个页面的源码,然后把文件名分离出来,接着跟把头链接跟拓展名与分离出来的文件名组合以后就形成了可下载的URL…
我使用的是VB,所以要分离删除文件名就Split来分离出来吧,组合URL就是
“ http://头链接就这样就OK了!” & Filename & “.flv”
代码:
VERSION 5.00
Begin VB.Form Form1
Caption = " 优酷视频下载工具 "
ClientHeight = 3210
ClientLeft = 60
ClientTop = 435
ClientWidth = 4680
LinkTopic = " Form1 "
ScaleHeight = 3210
ScaleWidth = 4680
StartUpPosition = 1 ' 所有者中心
Begin VB.Frame Frame1
Caption = " 说明: "
Height = 1815
Left = 120
TabIndex = 3
Top = 1200
Width = 4455
Begin VB.Label Label3
Caption = " 比如要下载光良的不会分离这个视频就直接把视频地址http://v.youku.com/v_show/id_cf00XMTIzNDExNzY= .html复制到上面的文本输入框就可以了 o(∩_∩)o...哈哈 "
Height = 975
Left = 120
TabIndex = 5
Top = 720
Width = 4215
End
Begin VB.Label Label2
Caption = " 直接把所要下载的视频的URL复制到上面的文本输入框里面就可以了^_^ "
Height = 495
Left = 120
TabIndex = 4
Top = 240
Width = 4215
End
End
Begin VB.CommandButton CmdOk
Caption = " 下 载 "
Height = 615
Left = 3720
TabIndex = 2
Top = 480
Width = 855
End
Begin VB.TextBox url
BeginProperty Font
Name = " 宋体 "
Size = 12
Charset = 134
Weight = 400
Underline = 0 ' False
Italic = 0 ' False
Strikethrough = 0 ' False
EndProperty
Height = 615
Left = 120
MultiLine = - 1 ' True
ScrollBars = 1 ' Horizontal
TabIndex = 1
Top = 480
Width = 3615
End
Begin VB.Label Link
Caption = " Isto-LivinG "
BeginProperty Font
Name = " 宋体 "
Size = 9
Charset = 134
Weight = 400
Underline = - 1 ' True
Italic = 0 ' False
Strikethrough = 0 ' False
EndProperty
ForeColor = & H00FF0000 &
Height = 255
Left = 3480
TabIndex = 6
Top = 120
Width = 1095
End
Begin VB.Label Label1
Caption = " 视频页面地址: "
Height = 255
Left = 120
TabIndex = 0
Top = 240
Width = 1335
End
End
Attribute VB_Name = " Form1 "
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function DoFileDownload Lib " shdocvw.dll " _
(ByVal lpszFile As String ) As Long
Private Declare Function ShellExecute Lib " shell32.dll " Alias " ShellExecuteA " (ByVal hwnd As Long , ByVal lpOperation As String , ByVal lpFile As String , ByVal lpParameters As String , ByVal lpDirectory As String , ByVal nShowCmd As Long ) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Sub CmdOk_Click()
Dim str As String
Dim Link As String
Dim sDownload As String
Set xmlHTTP1 = CreateObject ( " Microsoft.XMLHTTP " )
xmlHTTP1.Open " get " , url.Text, True
xmlHTTP1.send
While xmlHTTP1.readyState <> 4
DoEvents ' 转让系统控制权给CPU,好让CPU有空闲时间处理其他的事情,这样可以防止程序死锁
Wend
str = xmlHTTP1.responseText
Set xmlHTTP1 = Nothing
ary = Split (str, " =',' " )
ary = Split (ary( 2 ), " '); " )
Link = " http://121.14.140.22/ " & ary( 0 ) & " .flv "
sDownload = StrConv(Link, vbUnicode)
Call DoFileDownload(sDownload)
End Sub
Private Sub Link_Click()
Call ShellExecute(Me.hwnd, " open " , " http://blog.csdn.net/I_S_T_O " , vbNullString, vbNullString, SW_SHOWNORMAL)
End Sub
Begin VB.Form Form1
Caption = " 优酷视频下载工具 "
ClientHeight = 3210
ClientLeft = 60
ClientTop = 435
ClientWidth = 4680
LinkTopic = " Form1 "
ScaleHeight = 3210
ScaleWidth = 4680
StartUpPosition = 1 ' 所有者中心
Begin VB.Frame Frame1
Caption = " 说明: "
Height = 1815
Left = 120
TabIndex = 3
Top = 1200
Width = 4455
Begin VB.Label Label3
Caption = " 比如要下载光良的不会分离这个视频就直接把视频地址http://v.youku.com/v_show/id_cf00XMTIzNDExNzY= .html复制到上面的文本输入框就可以了 o(∩_∩)o...哈哈 "
Height = 975
Left = 120
TabIndex = 5
Top = 720
Width = 4215
End
Begin VB.Label Label2
Caption = " 直接把所要下载的视频的URL复制到上面的文本输入框里面就可以了^_^ "
Height = 495
Left = 120
TabIndex = 4
Top = 240
Width = 4215
End
End
Begin VB.CommandButton CmdOk
Caption = " 下 载 "
Height = 615
Left = 3720
TabIndex = 2
Top = 480
Width = 855
End
Begin VB.TextBox url
BeginProperty Font
Name = " 宋体 "
Size = 12
Charset = 134
Weight = 400
Underline = 0 ' False
Italic = 0 ' False
Strikethrough = 0 ' False
EndProperty
Height = 615
Left = 120
MultiLine = - 1 ' True
ScrollBars = 1 ' Horizontal
TabIndex = 1
Top = 480
Width = 3615
End
Begin VB.Label Link
Caption = " Isto-LivinG "
BeginProperty Font
Name = " 宋体 "
Size = 9
Charset = 134
Weight = 400
Underline = - 1 ' True
Italic = 0 ' False
Strikethrough = 0 ' False
EndProperty
ForeColor = & H00FF0000 &
Height = 255
Left = 3480
TabIndex = 6
Top = 120
Width = 1095
End
Begin VB.Label Label1
Caption = " 视频页面地址: "
Height = 255
Left = 120
TabIndex = 0
Top = 240
Width = 1335
End
End
Attribute VB_Name = " Form1 "
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function DoFileDownload Lib " shdocvw.dll " _
(ByVal lpszFile As String ) As Long
Private Declare Function ShellExecute Lib " shell32.dll " Alias " ShellExecuteA " (ByVal hwnd As Long , ByVal lpOperation As String , ByVal lpFile As String , ByVal lpParameters As String , ByVal lpDirectory As String , ByVal nShowCmd As Long ) As Long
Private Const SW_SHOWNORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Sub CmdOk_Click()
Dim str As String
Dim Link As String
Dim sDownload As String
Set xmlHTTP1 = CreateObject ( " Microsoft.XMLHTTP " )
xmlHTTP1.Open " get " , url.Text, True
xmlHTTP1.send
While xmlHTTP1.readyState <> 4
DoEvents ' 转让系统控制权给CPU,好让CPU有空闲时间处理其他的事情,这样可以防止程序死锁
Wend
str = xmlHTTP1.responseText
Set xmlHTTP1 = Nothing
ary = Split (str, " =',' " )
ary = Split (ary( 2 ), " '); " )
Link = " http://121.14.140.22/ " & ary( 0 ) & " .flv "
sDownload = StrConv(Link, vbUnicode)
Call DoFileDownload(sDownload)
End Sub
Private Sub Link_Click()
Call ShellExecute(Me.hwnd, " open " , " http://blog.csdn.net/I_S_T_O " , vbNullString, vbNullString, SW_SHOWNORMAL)
End Sub
直接把上面这些复制到文本里面保存为Form1.frm然后用VB程序打开就可以了!
哎...team里面我最菜了,只能发些小文章...大鸟飘过吧,小鸟也不要见笑了....