Retrieving HTML from the Internet.

Can someone give me an example of how i can use VB 6.0 to retrieve the html source code from any URL and save it as a file on my hard drive.  I want the saved file to contain the exact same information that i see when i navigate to a webpage with my web browser and select view source.

Thanks, Kallik
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There is a project on you Visual Basic CD that is a GREAT example...


By the way, on the "frmHTTPExplorer" form in that project, there are 3 panes... a Site document list on the left side, the HTTP source code in a RichTextBox in the upper-right side, and the actual document in the lower-left corner.

KallikAuthor Commented:
Unfortunately, i am only able to get this sample program to return the 1st 150 lines of HTML.  It also seems to be having a problem accepting a query string embedded within the URL name.  
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Check out Catalyst's SocketWrench.  The package comes with at least 10 examples on various socket uses.  Getting the source from an html page on a web server is one of them.
you can only get the first and 150 lines because of a bug in the internet transfer control. i had this same problem. microsoft has a "work around" but it doesn't always work. you can get more than 150 lines from some pages(which is all the lines) but not from all. sorry. alternatives would be to use the winsock controll but that would be much more dificult
KallikAuthor Commented:
Sorry, hess you are being helpful but the problem is far from solved.  I am not going to accept an answer until i get a solution.  I am increasing the points to 300 in the hopes that i can get this resolved today.  Sorry polaughlin i am not going to run out and buy a set of tools for something this trivial.

Thanks, Kallik
the win sock control can download the sorce code of a page no problem.

Public Sub GetURL(strURL As String)

    ' function to fetch a web page
    Dim s As String
    Winsock1.RemoteHost = "p133"'my MS Personal Web Server
    Winsock1.RemotePort = 80
End Function

Private Sub Winsock1_Connect()

    ' comes here when TCP/IP connection is made
    ' now, send message to connection to get web page
    Dim strURL String
    Dim strMsg String
    strURL = "http://p133/DEFAULT.HTM"
    strMsg = "GET " + strURL + " HTTP/1.0" + vbCrLf
    strMsg = strMsg + "Accept: */*" + vbCrLf
    strMsg = strMsg + "Accept: text/html" + vbCrLf
    strMsg = strMsg + vbCrLf
    Winsock1.SendData strMsg
End Sub

Private Sub Winsock1_Close()

    ' comes here when remote server closes connection
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)

    'comes here multiple times as data starts to arrive
    Dim rData As String
    Winsock1.GetData rData, vbString
    Text1.Text = Text1.Text + rData
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KallikAuthor Commented:
MikeTMike - That worked perfectly (fast too), thanks!!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.