Results 1 to 2 of 2

Thread: download webpage with frames using inet control - HOW?!

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    1

    Question

    Subject says it all. I have no problem downloading the html from a webpage, but how to do this if the damn webpage has frames!? I ain't gettin what I want off it! ARGH!

    Any help would be *greatly* appreciated! Thanks in advance!

    - Inet_Guy

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    You need to parse the frames page for the FRAME SRC tags

    try this:


    Code:
    Option Explicit
    Option Compare Text
    
    
    Public Sub DownLoad(remoteFile As String, localfile As String)
    'insert download code here
    Dim b() As Byte
    Dim fnum As Long
    On Error Resume Next
    fnum = FreeFile
    ' Retrieve the file as a byte array.
    b() = Inet1.OpenURL(remoteFile, icByteArray)
    Open localfile For Binary Access Write As #fnum
    Put #fnum, , b()
    Close #fnum
    
    End Sub
    
    Public Sub ParseFile(Filename As String)
    Dim fnum As Byte
    Dim strTemp As String
    Dim pos As Integer
    Dim strSRC As String
    Dim Char As String
    Dim i As Integer
    
    fnum = FreeFile
    
    Open Filename For Binary As fnum
      strTemp = Space(LOF(fnum))
      Get #fnum, , strTemp
    Close #fnum
    
    
    Do
      pos = InStr(strTemp, "frame ")
      If pos > 0 Then
        'trimto frame
        strTemp = Mid(strTemp, pos)
        
       'trim to src
        pos = InStr(strTemp, "SRC")
        strTemp = Mid(strTemp, pos)
        
        '<frame name="contents" src="contents.htm">
        
        'trim to "
        pos = InStr(strTemp, Chr(34))
        strTemp = Mid(strTemp, pos + 1)
         strSRC = ""
        For i = 1 To Len(strTemp)
          Char = Mid(strTemp, i, 1)
          If Char = Chr(34) Then
            Exit For
          Else
            strSRC = strSRC & Char
          End If
        Next i
        
        
        List1.AddItem strSRC
      Else
        Exit Do
      End If
      
        
    Loop
    
    
    End Sub
    
    Private Sub Command1_Click()
    Dim remoteRoot As String
    Dim i As Integer
    
    DownLoad Text1.Text, "c:\tempfile.htm"
    
    
    remoteRoot = GetRoot(Text1.Text)
     
    ParseFile "c:\tempfile.htm"
    
    'so far so good
    'now download the files
    
    For i = 0 To List1.ListCount - 1
      DownLoad remoteRoot & List1.List(i), "c:\myfiles\" & List1.List(i)
    
    Next i
    
    End Sub
    
    Private Function GetRoot(Filename As String) As String
    On Error Resume Next
    
        ' Return the path name from the full file name
        Dim Counter As Long
        Counter = Len(Filename)
        While Counter > 0 And Mid(Filename, Counter, 1) <> "/"
          Counter = Counter - 1
        Wend
        GetRoot = Left(Filename, Counter)
      End Function
    Mark
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width