Results 1 to 2 of 2

Thread: Some help with Inet and Webbrowser Controls

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2000
    Location
    Chicago, IL
    Posts
    26
    Hello All

    I need a little help on Inet and Webbrowser Controls. I need some help, I'm kinda stuck. I'm working with webbrowser and Inet controls. On a html page are absolute links. I chop off the url so what remains is the name of the html file or a directory. Example: if the website is www.abcdefg.com/page1.html becomes page1.html How would I go about saving these files?

    Please help me VB gurus! =)

    Thanks in advance!

  2. #2
    Fanatic Member
    Join Date
    Jan 2000
    Location
    Mobile, AL, USA
    Posts
    600

    This should get you started.

    If you are loading the webpage into the Webbrowser Control, you can use this code to save the file. To test it, put a command button and webbrowser control on a form and past this code into the VB Editor window.
    [code]Option Explicit

    Private Sub Command1_Click()
    WebBrowser1.Navigate2 "www.hotmail.com"
    End Sub

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If pDisp Is WebBrowser1.Object Then
    'Inner Text
    Open "C:\windows\desktop\webtext.txt" For Output As #1
    Write #1, WebBrowser1.Document.body.innertext
    Close #1

    'Inner HTML
    Open "C:\windows\desktop\webHTML.txt" For Output As #1
    Write #1, WebBrowser1.Document.body.innerhtml
    Close #1

    End 'the program
    End If
    End Sub

    If you want to use Inet, check out this info from MSDN:
    Saving to a File Using the OpenURL Method
    If you wish to save the data retrieved through the
    OpenURL method to a file, use the Open, Put, and Close
    statements, as shown in the code below. This example
    streams a binary file into a Byte array before saving the
    data to disk:

    Code:
    Dim strURL As String
    Dim bData() As Byte      ' Data variable
    Dim intFile As Integer   ' FreeFile variable
    strURL = _
    "ftp://ftp.microsoft.com/Softlib/Softlib.exe"
    intFile = FreeFile()      ' Set intFile to an unused
                            ' file.
    ' The result of the OpenURL method goes into the Byte 
    ' array, and the Byte array is then saved to disk.
    bData() = Inet1.OpenURL(strURL, icByteArray)
    Open "C:\Temp\Softlib.exe" For Binary Access Write _ 
    As #intFile
    Put #intFile, , bData()
    Close #intFile
    For further help with Inet, check out Using the Internet Transfer Control in MSDN.

    All the best.

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