[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Retrieving HTML from the Internet.

Posted on 1999-12-29
8
Medium Priority
?
278 Views
Last Modified: 2013-11-13
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
0
Comment
Question by:Kallik
8 Comments
 
LVL 14

Expert Comment

by:mcrider
ID: 2313223
There is a project on you Visual Basic CD that is a GREAT example...

It's located in \TOOLS\UNSUPPRT\HTTPEXPL


Cheers!
0
 
LVL 14

Expert Comment

by:mcrider
ID: 2313241
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.


Cheers!
0
 
LVL 1

Author Comment

by:Kallik
ID: 2313463
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.  
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

Expert Comment

by:polaughlin
ID: 2313743
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.

http://www.catalyst.com
0
 

Expert Comment

by:hess
ID: 2313784
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
0
 
LVL 1

Author Comment

by:Kallik
ID: 2314909
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
0
 
LVL 1

Accepted Solution

by:
mikeTmike earned 1200 total points
ID: 2315182
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
    Winsock1.Connect
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
    Winsock1.Close
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
0
 
LVL 1

Author Comment

by:Kallik
ID: 2315531
MikeTMike - That worked perfectly (fast too), thanks!!!!
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question