Link to home
Start Free TrialLog in
Avatar of hteel
hteelFlag for United States of America

asked on

Pull HTML Code for a Website Using VB.net

I have some experience using VB 6.0, but would like to learn VB.net.  A project I would like to begin with is this:

I would like to create code that would go to a particular website, say something like www.yahoo.com.  I then want to save the HTML code for that site to a text file on my PC.  Is this possible?  If so, how would I begin?

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Timbo87
Timbo87

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Howard Cantrell
Hi  hteel,

Here is some code that I use...
Add Reference........ AxInetCtlsObjects.dll

Private sWebCode as string
   
 Private Sub LoadData()
        Dim sFile As String

        Try
            'This will display the final screen of data from USAPUB
            sFile = "http://MyWebsiteSearch"      '<---- Replace with your url, Copy source code from web site
            sWebCode = AxInet.OpenURL(sFile)
            WriteCodeTo(sWebCode)               '<---make a procedure to write string to a text file (a streamWriter).
        Catch exp As NullReferenceException
        Catch exp As Runtime.InteropServices.COMException
        Catch exp As Exception
            MsgBox(exp.Message, MsgBoxStyle.Critical, "General Error")
        End Try
    End Sub