Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Stream 1

Status
Not open for further replies.

GP1

Programmer
Jan 15, 2002
23
0
0
NO
Hi,
I want to create a component that when given a URL can connect to the site and get all the html from that page (html, asp, jsp etc..) as a text stream (String variable). Then I can parse the HTML for any purpose. Can this be done. If so please tell me what I need to do. Code would be a great help.

Thanks
 
I have the same problem.
txtNote.Text = Inet1.OpenURL(creates the string from the URL and puts it in txtNote.Text, but some of the info is missing. I would like to find out how to get all the info.
Chuck
 
Add a webbrowser to a form, and a reference to the HTML library. The play with the following code:
[tt]
Option Explicit

Private Sub Command1_Click()

WebBrowser1.Navigate &quot;<URL>&quot;

End Sub

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim mydoc As HTMLDocument
Set mydoc = WebBrowser1.Document
Debug.Print mydoc.childNodes(0).outerHTML
End Sub
 
strongm
Hi, Thanks for the code. I did try out your code, and it works. But I dont want to display the HTML in the browser. I want to get the HTML in to a text box or string. I want to write a component without a form. Can you help me out please.

Thanks,
Gavin
 
to gp1
this works 99% of the time:

dim txtNote.Text as string
txtNote.Text = Inet1.OpenURL(
creates the string from the URL and puts it in txtNote.Text
you need the internet transfer control installed in the form.
I need a fix for the 1% of the time it does not work. I have been told that the 1% is a bug in vb6 and there is a fix but I have not found it.
cdollins
 
cdollins
Hi. Thanks yes it works fine. But how can I do this sort of thing withought having a form. I want to write a com component that reads URLs..

Thanks,
Gavin

 
Gavin,

You just need to rework the example slightly. Here's a version that requires no form. Just add a reference to the Microsoft HTML Object Library, and drop this example into a code module (you should be able to easily work it into a class):
[tt]
Option Explicit

Public Sub demo()
Debug.Print GetURLText(&quot;End Sub

Public Function GetURLText(strUrl) As String
Dim DocumentFactory As HTMLDocument ' Factory object
Dim myRealDoc As HTMLDocument

Set DocumentFactory = New HTMLDocument

Set myRealDoc = DocumentFactory.createDocumentFromUrl(strUrl, vbNullString)
' Wait until ready
Do Until myRealDoc.readyState = &quot;complete&quot;
DoEvents
Loop

GetURLText = myRealDoc.childNodes(0).outerHTML

End Function
 
Nutz - the dratted tek-tips parser keeps adding a semi-colon after the embedded URL. I'm sure you've worked out that it shouldn't be there.
 
Hi strongm,
Thanks the code works perfectly. Thanks again to all those who replyed.

Thanks,
Gavin
 
Hi,
Any I dea how to use the &quot;Microsoft Internett Controls&quot; DLL to test whether a url is valid, or whether the site is up ?

Thanks,
Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top