想作一个程序用来抓网页上的文本及网页上的图片和FLASH,文本比较好说了,图片和FLASH怎么抓呢?如果使用WEBBROWER的话,我感觉图片及FLASH应该已经存在本地的IE缓存里了,怎样想办法把他们找出来?另外,不使用WEBBROWER的话还有其他更有效的办法吗?

解决方案 »

  1.   

    从网页下载图片的程序
    Private Sub GetLinks()
      Dim Doc     As IHTMLDocument2
      Dim All     As IHTMLElementCollection
      Dim L     As Integer
      Dim i     As Integer
      Dim Varl     As Variant
     
      Set Doc = WebBrowser1.Document
      Set All = Doc.images   L = All.length
      For i = 0 To L - 1
            Set Varl = All.Item(i, varempty)
              List1.AddItem (Varl.href)
             
            Set Varl = Nothing
      Next i
      Set All = Nothing
      Set Doc = Nothing
      Label1.Caption = List1.ListCount + 1
      End Sub
        
      Private Sub Command1_Click()
     For i = 0 To List1.ListCount - 1
    downFile List1.List(i)
     Next
      End Sub
        
      Private Sub Form_Load()
     WebBrowser1.Navigate "http://zy.muwen.com/pic/85/2008/07/15/142868.htm"
      End Sub
        
      Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, url As Variant)
      GetLinks
      End Sub
        
      Private Function downFile(url As String)
            Dim bytes() As Byte
            bytes() = Form1.Inet1.OpenURL(url, icByteArray)
            Dim tempS
             tempS = Split(url, "/")
            Dim fName As String
            fName = tempS(UBound(tempS))
           fName = App.Path & "\" & "图片" & "\" & fName
            Open fName For Binary Access Write As #1
                    Put #1, , bytes()
            Close #1
    End Function